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
Feature/coupon syncer #1014
Feature/coupon syncer #1014
Conversation
Thanks @chennyxie ! |
Thanks for the PR @chennyxie! I noticed in the list of commits, there seem to be numerous additional commits besides the ones that you made. I would recommend rebasing against the |
3a5eb0b
to
e335d33
Compare
Hi, JPry, Do you think if it will help to update this "woocommerce:feature/1008-coupon-integration" branch to the current develop, so that only my commits are shown in this PR? thanks |
@chennyxie Yes, I think this PR should target the |
@JPry I set up this as a feature branch so that we can choose when to merge to develop and release |
Ah, sorry, I wasn't aware of that. In that case, it definitely sounds like we should stick with the That also means that the rebase should take place against the |
… for the triggerings
fix MC dependency in coupon visibility box fix
e335d33
to
d51dc81
Compare
Hi, I have rebased this PR again according to the comments above. Now it should be ready for review. Thanks |
Thanks @chennyxie that looks better! Cheers 🍻 |
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.
@chennyxie I've gone through and tested this functionality on my test site. Setting up a coupon is working well, and I can see that they sync to Google is "pending". Do you know how long it would typically take for the sync to occur?
On a first look, the logic looks to be sound in your code. I'll take another pass tomorrow to see if there's anything else to adjust. Until then, the biggest thing I've noticed is related to the project code style. I've added a few suggestions below, but it looks like some of the files need more comprehensive adjustments. Could you please make changes based on running ./vendor/bin/phpcs
?
1441d16
to
e4425ef
Compare
587ae2f
to
4891b19
Compare
@JPry can you give the last few commits a once over to check they are all good. I noticed in 9f3b231#diff-55e830624fd3dfe830824f42db8d5cd251b37c1d637d837435cbd48f8d15e1dfL219 we might be losing some debugging Then I think we can merge and get ready for release on Tuesday |
*/ | ||
public function mark_as_synced( | ||
WC_Coupon $coupon, | ||
string $google_id, | ||
?string $google_id, |
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.
In which cases this can be a null value? Shouldn't all synced coupons have an ID?
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 is to be compatible to the alpha version of content API and the id will be used in later version.
During some usage testing, a This happened when trying to sync a coupon with a linked, existing Merchant Center account (that is, not a new Merchant Center account created under our MCA). My best guess is that the MCA can't manipulate promotions for linked accounts (unlike for sub-accounts), and since the Does this sound correct? Is there any workaround for this? Or will this access limitation be removed once the Promotions feature goes public? |
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.
The code looks good to merge but I did leave a bunch of comments that need to be addressed in a subsequent PR. Justin has tested this and left a comment with the results here: #1014 (comment)
* | ||
* @return array | ||
*/ | ||
public static function convert_product_types( $category_ids ): array { |
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's probably best to make these methods (this one and get_google_product_offer_id
) protected
if we're not using them anywhere else. Especially given that this class isn't a utility class.
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.
convert_product_types and get_google_product_offer_id are also used in WCCouponAdapter, the 2 adapters share some product info conversion method to guarantee product attributes matches the coupon restrictions related to product ids or product categories. We can consider to create a utility for adapters in the followup improvements.
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.
Ah, okay then I would definitely vote for a utility class since that's not a functionality specific to the WCProductAdapter.
Hi, yes, as the Google documentation says, currently promotion API is open for limited access, so a MC account that not managed by WooCommerce MCA are not open to use this alpha version, which should be resolved once we open the API to public.
|
Thanks @chennyxie just needed to confirm as the e2e tests note that "we made this case by disabling promotion API access from Google side" and weren't sure if we still had some access disabled etc. |
238fecf
to
4891b19
Compare
Hi, the API access issue for the account linking of an existing MC account has been resolved now, be free to retry the test to verify it |
Hi @chennyxie, I just ran a quick test and it looks like the issue with linked accounts is fixed - they go to However, I'm seeing an issue with coupons created in stores targeting a non-US country. When I set up a store targeting somewhere else ( In the log, it shows the job running (
Should this message be displayed in the Coupon form (I thought I saw it at some point before)? Or should the coupon be updated even though the target country is non-US? |
Hi, thanks for catching this. Seems I missed one commit(during mistakenly click fix on this PR page and which the conflict with my local committed fix) with a force push, I have added the commit back |
Thanks @chennyxie 👏 |
👍🏻 I've done a bit more usage testing and functionally, it looks good:
I'm going to merge this PR into the |
Closes #1008
GooglePromotionService is released in https://github.com/googleapis/google-api-php-client-services (v0.211.0 and above)
Note that createPromotion API works for create or update as long as using same promotion id. In addition, we use create with set effective dates as expired to disable the promotion.
Major files that are added:
Screenshots:
Detailed test instructions:
Changelog entry