-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merchant Center Settings Sync #255
Conversation
f6eb5bf
to
edf06a4
Compare
Ok refreshed my memory - the idea is this would add a post code and estimated delivery value to the conversion tag. So I don’t think you need to do anything here" (We'll likely end up removing this functionality / delaying it) |
Looks like this doesn't include tax settings yet |
I've updated the main PR description to indicate this is currently only a part fix for #149 From what I can tell it still needs to be updated to sync tax settings at a minimum. We also still need to be able to do the following
We may need an additional approach that covers all the things - as it is currently, it doesn't appear to do enough for the complete setup button. @layoutd sorry to take you off other items, could you please jump in to review and lend a hand on this to get it across the line as a priority (given you've looked at tax and shipping settings during our research spikes). Based on a convo with @JPry today I don't think he had anything else in to push up so I don't believe there would be any stepping on toes if you were to make some additions before he jumps on (famous last words I guess). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was reviewing a bit earlier, but it looks like you're still cranking along so I'll just leave a few observations and notes.
Works well for me, syncs the shipping rates with the MC account I linked. Hopefully one-way sync won't be problematic for users who already have an MC account set up and are just linking it to the extension (it would overwrite all their configuration). Should this be considered or at least the user notified that any current settings will be overwritten (if they don't choose the I'll set this up manually in the Merchant Center
option)? Maybe @j111q knows?
A few other notes:
- This is the first time I've explicitly considered
add
vsshare
in the ServiceProviders; it may be worthwhile to audit theadd
s and see if any would be better as ashare
. - Are exception messages generally translatable? I know in MC and Ads a lot of them are, but it looks like none of the native Exceptions are.
- The exception when not linked to an MC account is a bit janky, not sure if some of the info should be going to the debugger before returning a cleaner error:
{
"code": "gla_setting_sync_error",
"message": "{\n \"error\": {\n \"code\": 401,\n \"message\": \"User cannot access account 0\",\n \"errors\": [\n {\n \"message\": \"User cannot access account 0\",\n \"domain\": \"content.ContentErrorDomain\",\n \"reason\": \"auth/account_access_denied\"\n }\n ]\n }\n}\n",
"data": {
"status": 500,
"message": "{\n \"error\": {\n \"code\": 401,\n \"message\": \"User cannot access account 0\",\n \"errors\": [\n {\n \"message\": \"User cannot access account 0\",\n \"domain\": \"content.ContentErrorDomain\",\n \"reason\": \"auth/account_access_denied\"\n }\n ]\n }\n}\n"
}
}
vs
google-listings-and-ads/src/API/Google/Proxy.php
Lines 269 to 274 in c58f132
} catch ( ApiException $e ) { | |
do_action( 'gla_ads_client_exception', $e, __METHOD__ ); | |
/* translators: %s Error message */ | |
throw new Exception( sprintf( __( 'Error retrieving accounts: %s', 'google-listings-and-ads' ), $e->getBasicMessage() ) ); | |
} |
Hmmm good question here. I'm assuming it will be pretty clear they're configuring something new and we don't need to explicitly call it out that we'll be overwriting any existing settings, but who knows if that assumption is correct. 🤔 Let's leave it as is for now - I feel like we're already bombarding them with a lot of tiny text - and let me add it into the Knowledge Base as documentation: And let me add this to our feedback sheet as one thing to consider for the next iteration. Thanks @layoutd ! |
I haven't checked in the code, but just to confirm - if the user picks the manual options we definitely don't want to override anything. |
Yeah, this is taken into consideration and I suppose it will be possible to update the shipping rates later on in case a user realizes they've overwritten their previous manual setup. |
@layoutd Thanks for the feedback!
To provide more context, the I agree an audit is probably needed, but with that in mind I think we should generally prefer using
My opinion is that exception messages generally shouldn't be translated. The exception (😅 no pun intended!) is when they're conveying information to the end user. Many of our exceptions are essentially guarding against bad development practices, or handling errors that we can't control. If they still get passed to the end user in some form, I'm OK with them being wrapped with a translated message that says "here's the error message". One of the reasons I think that exceptions generally shouldn't be translated is because it aids in users, support, and developers in easily tracking down problems. Trying to figure out where in the code a translated exception is thrown can be challenging. But of course there are times when I think the messages should be translated, and that's OK.
I've added some extra handling in 8b42ab2 to try to help with this. |
✅ From what I can tell it still needs to be updated to sync tax settings at a minimum.
I've added an action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! My shipping and tax settings were synced correctly generally. Is the "Free shipping under X" setting correct (see comment)?
The only other notes I had:
- I assume hardcoding the
LocationID
/Parent ID
from Google's Geotargeting CSV intoLocationIDTrait
is OK since the state codes won't change? - Looking at the shipping services in the MC panel, there's one small difference (but not particularly important). When you create a "Flat Rate" in the panel, it shows in the "Cost" section:
But for whatever reason, when we create a flat rate in the extension with the API it still ends up displaying as a rate table ("Cost" section):
I was fudging around with it in the Content API tester but even when I used shippingsettings.update
with the exact same data as provided in shippingsettings.get
, the manual shipping service also ended up switching to a rate table, so I haven't seen any way to change it.
$services[] = $this->create_main_service( $country, $currency, $rate ); | ||
|
||
if ( $this->has_free_shipping_option() ) { | ||
$services[] = $this->create_free_shipping_service( $country, $currency ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates two services for the country I think, is that correct?
Yes. I didn't see another way to do it. It looks like multiple rates within the same service need some kind of shipping label on the products to distinguish the rates.
Also, I think the free shipping service is created with a minimum price of 0, but the Figma shows the user selecting free shipping above a certain price.
Ah yes, good catch. I'll get that fixed up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like multiple rates within the same service need some kind of shipping label on the products to distinguish the rates.
When I set it up in the panel, it created this rate group, where I specified "20 € shipping up to 100 €, then free above that". I guess it's set up as a rate table (mainTable
) with rowHeaders->prices
and rows->cells
, but if the double services work, then that's definitely easier.
I don't mind, they're a priority for today. |
Correct, these aren't going to be changing. Since their CSV file is quite large with all possible location IDs, I think it makes more sense to just copy the portion we need. If we ever get to the point of adding more locations, we could revisit this. |
824253e
to
099c576
Compare
099c576
to
5815210
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Confirmed gla_mc_setup_completed_at
updated
✅ Confirmed products submitted
✅ No errors in my PHP logs or JS console errors
🟠 confirmed shipping settings updated - probably need an extra check for the use "manual" option
🟠 ✅ I couldn't tell if taxes were updated on my account (Update got it working)
Can also confirm that if we upload settings it definitely deletes/overrides any existing services set 😅 So need to be careful about this
I used the UI (from trunk) and it seemed to work well for my testing
Shipping Settings
I think this is related to one of @layoutd 's points - it's bit of a bummer that there doesn't seem to be an easy way to use the equivalent "Basic Cost settings" (or is there 🤔 - I'm guessing not by the looks)
One issue I hit is... if I select that I have simple shipping, add a value etc. and then decide "No, wait my setup is too complex, I'll just do things manually" and change my choice - the shipping settings are still updated (and override what I have already - confirmed this as well).
I think we need to an extra check before syncing to make sure that "shipping_rate" is not actually set to "manual". Looks like we just check if there are rates in the DB.
Alternatively, I think we'd need to clear rates in the DB if the manual option is chosen.
Also a couple of questions for @j111q
1. we have the option for
I also offer free shipping for all countries for ** products** over a certain price.
Looks like the implementation for this in the MC dashboard is actually worded as
Minimum order value (optional)
Another example when using their "basic settings" - it also mentions order value
@j111q did you come across something in the MC that allows free shipping for products over a certain price? Or should we change this to say "orders" for consistency? (Not really a blocker for this PR if decide to change the wording)
2. I think the shipping times and rates are pretty closely coupled. If a Merchant decides to set up shipping rates manually, I'm thinking we don't really need to ask them to tell us shipping times. This isn't specific for this PR, we can have a think and do this a follow-up but at the moment I think we still ask for times when the manual option is set for rates and we won't actually do anything as we don't create any shipping services without a rate set.
Tax Settings
I don't get any errors but mine just shows up as Got it, see below
Ok I can see what is happening - there is a disconnect between the UI and handling here. The UI shows the onboarding US tax settings if we are targeting the US but in this PR we only sync tax settings if the store is "located" in the USA. Got it working and confirmed it synced. Something for the feedback/ideas doc @j111q - do we want to add an option here for "Is shipping and handling taxable?" To cover the checkbox in this screenshot >> |
Which are we actually wanting to go with? I did it this way thinking that it was only relevant for stores that are located in the US vs. shipping to the US. But if that was just a misunderstanding on my end we can change it.
👍🏻 |
Merging. I'm going to create a couple follow up issues to investigate as we do more testing:
|
The reason why I used "products" and not "orders" is because this is relevant for the shipping fee that will be displayed in the product listing in Google. I think that's a fair point to align with Google and change it to "orders" - which the merchant will be more familiar with, offering free shipping over $x in an order - and I suppose Google does the work of translating that "free shipping over $x" to individual product listings which are priced over "$x".
I'm trying to redesign this now, to combine "shipping rates and times" together. Will hopefully update soon! |
Okay, here is the updated design for the "combined shipping rates and times": https://d.pr/i/aPCjIt I tried to keep it as close to the original as possible, while still making it user-friendly - it IS an intimidating setting. I need some help creating follow-up issues 'cause I'm not sure where they'd go at this point 😅 Appreciate any feedback or questions on the design though. Also, if this design change doesn't make it in for Tranche 2 (likely won't, since we're pushing for that this week), I think it's fine. We can just make a special note of it to testers and ask them to choose manual for both or neither. |
@j111q I'm still in the process of setting the shipping rate and time for edit campaign flow. I guess, your change above applies also there. Should I try to incorporate it there, or for v0, let's leave it as is in Setup flow, to keep it consistent? (keeping it consistent, naturally would go slightly faster) |
Thanks for calling that out @tomalec - yes, the key is that it should be consistent, so whenever this is incorporated in the Setup flow, it should also be changed in the Edit flow. 🙏 Thank you! |
Consistent is ideal - If you start making the changes in the edit flow now @tomalec can we then port them back to the main onboarding flow when done? (That's a simplistic view of it obviously - but I believe that is roughly the approach you are taking updating components there at the moment anyway) - we can chat tonight. |
Created a follow-up issue to track redesigned shipping rates & times #335 |
Changes proposed in this Pull Request:
This PR facilitates saving of our settings to the Merchant Center via the API. Here are the notable components:
\Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Settings
class – This class contains all the logic needed to synchronize settings with Google. This is accomplished via two public methods:sync_shipping()
andsync_taxes()
.\Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\SettingsSyncController
class – This class adds an API endpoint to trigger the settings to be synchronized with Google. The endpoint is:This endpoint does not take any data. It uses the data already saved to the database to generate the request to Google.
The endpoint handles calling the methods mentioned in the
Settings
class above. It will also trigger a new actiongla_mc_settings_sync
. This action can be used elsewhere in the codebase to facilitate other activity that needs to be handled after settings have been sent to Google.\Automattic\WooCommerce\GoogleListingsAndAds\Value
namespace. These are not currently being used, but I would like to see them used in the future. They can be reviewed or ignored, or I can pull them out of this PR and save them for another time since they are not used.Part of #149