Skip to content
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

Adjust auto-sync shipping option #2526

Merged

Conversation

jorgemd24
Copy link
Contributor

@jorgemd24 jorgemd24 commented Aug 14, 2024

Changes proposed in this Pull Request:

Part of pcTzPl-2qP-p2

This PR includes the following changes:

  1. Removes the "Recommended" label from the auto-sync option.
  2. By default, selects the manual option ("My shipping settings are simple. I can manually estimate flat shipping rates.") if no shipping settings were previously stored, such as during onboarding.
  3. Hides the auto-sync option during onboarding if the merchant has no shipping methods set up.

Onboarding:

t6I53r.mp4

Editing Page (the auto-sync option is always displayed, regardless of shipping settings):

Cu84V6.mp4

Detailed test instructions:

  1. Disconnect all your accounts and remove any shipping method in WC.
  2. Go to GFW onboarding.
  3. When setting up the Shipping Rates, see that the auto-sync option is not available.
  4. In WC add a new shipping method.
  5. Refresh the onboarding page.
  6. See that the auto-sync option is available.
  7. See that always the option: My shipping settings are simple. I can manually estimate flat shipping rates is checked.
  8. Finish the onboarding.
  9. Go to Edit Free Listings and see that the auto-sync option is always displayed, regardless of shipping settings

Additional details:

  • Local Pickup isn't currently recognized as a valid shipping method, but it looks like we're not syncing it to Google either. So, I think it's fine if Local Pickup isn't counted as a valid method in this case.
  • While working on this, I discovered a bug. If you use a comma as the decimal separator, the shipping rate won't be recognized as valid because is_numeric will return false. I'll create the issue.

image

if ( is_numeric( $cost ) ) {
$flat_cost = (float) $cost;
$rate = $flat_cost;
}

Changelog entry

@github-actions github-actions bot added the changelog: tweak Small change, that isn't actually very important. label Aug 14, 2024
@jorgemd24 jorgemd24 changed the title Tweak/shipping adjustments Adjust auto-sync shipping option Aug 14, 2024
@jorgemd24 jorgemd24 self-assigned this Aug 14, 2024
@jorgemd24 jorgemd24 requested a review from a team August 14, 2024 16:27
Copy link

codecov bot commented Aug 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.2%. Comparing base (3ea16ba) to head (8f3231f).
Report is 11 commits behind head on update/shippings-settings-phase-1.

Additional details and impacted files

Impacted file tree graph

@@                          Coverage Diff                          @@
##             update/shippings-settings-phase-1   #2526     +/-   ##
=====================================================================
+ Coverage                                 65.0%   65.2%   +0.3%     
- Complexity                                4585    4588      +3     
=====================================================================
  Files                                      476     803    +327     
  Lines                                    17898   23012   +5114     
  Branches                                     0    1234   +1234     
=====================================================================
+ Hits                                     11626   15012   +3386     
- Misses                                    6272    7833   +1561     
- Partials                                     0     167    +167     
Flag Coverage Δ
js-unit-tests 64.0% <100.0%> (?)
php-unit-tests 65.6% <100.0%> (+0.6%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...nts/shipping-rate-section/shipping-rate-section.js 100.0% <100.0%> (ø)
.../src/setup-mc/setup-stepper/saved-setup-stepper.js 87.8% <ø> (ø)
.../Controllers/MerchantCenter/SettingsController.php 97.9% <100.0%> (+83.2%) ⬆️
...ernal/DependencyManagement/RESTServiceProvider.php 100.0% <100.0%> (ø)
src/Shipping/ShippingZone.php 97.9% <100.0%> (+0.1%) ⬆️

... and 325 files with indirect coverage changes

@jorgemd24 jorgemd24 marked this pull request as ready for review August 14, 2024 16:32
@@ -71,6 +90,9 @@ protected function get_settings_endpoint_edit_callback(): callable {
}

foreach ( $schema as $key => $property ) {
if ( ! in_array( 'edit', $property['context'] ?? [], true ) ) {
Copy link
Contributor Author

@jorgemd24 jorgemd24 Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this so it skips only view properties; otherwise, it would save them as options, like the shipping_rates_count property.

Comment on lines 35 to 37
mcSetup?.status === 'incomplete'
? true
: false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified as just mcSetup?.status === 'incomplete'

Comment on lines 68 to 77
{ ...inputProps }
label={ createInterpolateElement(
__(
'Automatically sync my store’s shipping settings to Google.',
'google-listings-and-ads'
),
{
strong: <strong></strong>,
}
) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we dont use anymore tag we can omit createInterpolateElement and just use

label={
					__(
											'Automatically sync my store’s shipping settings to Google.',
											'google-listings-and-ads'
										)
}
								

@puntope
Copy link
Contributor

puntope commented Aug 16, 2024

@jorgemd24 I set a shipping method (flat) but still, I don't see the auto-sync option. If I add free shipping yes it works.

Screen.Recording.2024-08-16.at.13.27.02.mov

@jorgemd24
Copy link
Contributor Author

Thanks @puntope for the review and your suggestions!

I set a shipping method (flat) but still, I don't see the auto-sync option. If I add free shipping yes it works.

Could it be that the issue is related to using a comma instead of a dot for decimal pricing? I encountered a similar problem while working on this #2527, Could you share a screenshot of how the flat rate is set up?

Also, could you provide a screenshot of the response from the settings endpoint?

image

Thanks!

@jorgemd24 jorgemd24 requested a review from puntope August 22, 2024 14:57
@puntope
Copy link
Contributor

puntope commented Aug 23, 2024

Could it be that the issue is related to using a comma instead of a dot for decimal pricing? I encountered a similar problem while working on this #2527, Could you share a screenshot of how the flat rate is set up?

Hi @jorgemd24 I tested it again. Seems like it's because the price field was empty. If I add a value (0, -1, 0.0, 0,0) it works

Also, could you provide a screenshot of the response from the settings endpoint?

{
    "shipping_rate": "flat",
    "shipping_time": "flat",
    "tax_rate": "destination",
    "website_live": true,
    "checkout_process_secure": true,
    "payment_methods_visible": true,
    "refund_tos_visible": true,
    "contact_info_visible": true,
    "shipping_rates_count": 0
}

@jorgemd24
Copy link
Contributor Author

Seems like it's because the price field was empty

Hi @puntope, you need to have valid shipping methods for the auto sync option to be displayed; otherwise, it won't show up. For example, something like this should work:

image

The original idea was to show the auto-sync option only if there are valid shipping methods. The logic for syncing shipping to MC was already implemented, and this PR is simply leveraging that code.

Copy link
Contributor

@puntope puntope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @jorgemd24 Thanks for clarifying the issue with the empty shipping method.

@jorgemd24 jorgemd24 merged commit 8cbbde7 into update/shippings-settings-phase-1 Sep 3, 2024
15 checks passed
@jorgemd24 jorgemd24 deleted the tweak/shipping-adjustments branch September 3, 2024 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: tweak Small change, that isn't actually very important.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants