[Backport to release/10.6] Fix checkout cart [shortcode] Shipment label is not correct#63649
Conversation
* Show shipping package title as "Shipment" instead of "Shipment 1" if there is only 1 package. Closes #63336. * add changelog * Cleanup the logic around showing the package number * Update tests for the introduced change * Update filter docs --------- Co-authored-by: helgatheviking <[email protected]>
Testing GuidelinesHi @samnajian @senadir , Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
|
Dear WooCommerce Support Team, After updating our store to WooCommerce version 10.6.1, we noticed that the recent fix introduced the label “Shipment” instead of “Shipment 1” on the checkout page, which we understand was intended as an improvement. However, we are currently facing another issue related to this change. In our store, we previously customized this label to “Delivery Charges” using Loco Translate. After the update, the text “Shipment” no longer appears in the translation strings, and even when we attempt to translate it through Loco Translate, the label on the checkout page does not change. This creates a problem because our checkout page now displays “Shipment”, while our store terminology requires “Delivery Charges” for better clarity for customers. We kindly request your team to review this behavior and advise whether: The string “Shipment” is now generated dynamically and therefore cannot be translated via standard translation files. For reference, this issue started after the fix mentioned in the WooCommerce changelog: We would greatly appreciate your guidance on how to properly change this label to “Delivery Charges.” Thank you for your continued support and for the improvements your team brings to WooCommerce. |
|
@jpelectronicindia-droid Does the string not show up after you press "Sync" in Loco Translate? (the button is visible on the image you posted) add_filter('gettext_with_context_woocommerce', function($translation, $text, $context) {
if($context === 'shipping packages') {
if($text === 'Shipment') {
return 'Delivery Charges';
}
if($text === 'Shipment %d') {
return 'Delivery Charges %d';
}
}
return $translation;
}, 10, 3); |
|
Dear WooCommerce Support Team, After pressing “Sync” in Loco Translate, the string “Shipment” still does not appear in the translation list. Because of this, it cannot be translated directly through Loco Translate. As a temporary workaround, we tested the following filter in the child theme’s add_filter('gettext_with_context_woocommerce', function($translation, $text, $context) {
if($context === 'shipping packages') {
if($text === 'Shipment') {
return 'Delivery Charges';
}
if($text === 'Shipment %d') {
return 'Delivery Charges %d';
}
}
return $translation;
}, 10, 3);However, the issue remains that the string added/changed via Loco Translate is not detected or translated, even after syncing. Could you please advise on how this string can be properly made translatable in Loco Translate, or confirm if this is a known issue introduced in WooCommerce 10.5? |
|
Dear WooCommerce Support Team,
After pressing *“Sync”* in Loco Translate, the string *“Shipment”* still
does not appear in the translation list. Because of this, it cannot be
translated directly through Loco Translate.
As a temporary workaround, we tested the following filter in the child
theme’s functions.php, which successfully changes the label from
*“Shipment”* to *“Delivery Charges”* on the checkout page:
add_filter('gettext_with_context_woocommerce', function($translation,
$text, $context) {
if($context === 'shipping packages') {
if($text === 'Shipment') {
return 'Delivery Charges';
}
if($text === 'Shipment %d') {
return 'Delivery Charges %d';
}
}
return $translation;
}, 10, 3);
However, the issue remains that the *string added/changed via Loco
Translate is not detected or translated*, even after syncing.
Could you please advise on how this string can be properly made
translatable in *Loco Translate*, or confirm if this is a known issue
introduced in *WooCommerce 10.5*?
|
@jpelectronicindia-droid |
This PR is a cherry-pick of #63645 to
release/10.6.Original PR Description
This PR is a follow up to #63346, please follow up the instructions on #63346 for testing
Show shipping package title as "Shipment" instead of "Shipment 1" if there is only 1 package.
Changes proposed in this Pull Request:
Send the count of the total number of packages to the
get_shipping_package_name()method so that the package can be conditionally named "Shipment" if there is only 1 package in total.... or "Shipment 1", "Shipment 2", etc if there are multiple packages.Closes #63336.
(For Bug Fixes)
Potentially introduced in daae10d#diff-cdc9f1829f52d7b83e3542948622d924ef5cf6a3e0b4580e6ebd1c9643bc49b4L261 .
Screenshots or screen recordings:
Before:

After:

more than 1 package will still show the same... "Shipment 1, Shipment 2, etc"
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Testing that has already taken place:
Milestone
Automatically assign milestone for the next WooCommerce versionChangelog entry
Automatically create a changelog entry from the details below.This Pull Request does not require a changelog entry. (Comment required below)Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment
Summary by CodeRabbit
Bug Fixes