Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit cb66063

Browse files
Always show the Enable the shipping calculator on the cart page option in WC Admin (#11421)
* Always show `Enable the shipping calculator ...` Always show the `Enable the shipping calculator on the cart page` option no matter of what is used for the cart page. * Update remove_shipping_settings docblock to accurately describe its purpose. --------- Co-authored-by: Mike Jolley <[email protected]>
1 parent a58aa3d commit cb66063

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

src/Shipping/ShippingController.php

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -171,52 +171,12 @@ public function show_local_pickup_details( $return, $order ) {
171171
}
172172

173173
/**
174-
* If the Checkout block Remove shipping settings from WC Core's admin panels that are now block settings.
174+
* When using the cart and checkout blocks this method is used to adjust core shipping settings via a filter hook.
175175
*
176176
* @param array $settings The default WC shipping settings.
177-
* @return array|mixed The filtered settings with relevant items removed.
177+
* @return array|mixed The filtered settings.
178178
*/
179179
public function remove_shipping_settings( $settings ) {
180-
181-
// Do not add the shipping calculator setting if the Cart block is not used on the WC cart page.
182-
if ( CartCheckoutUtils::is_cart_block_default() ) {
183-
184-
// Ensure the 'Calculations' title is added to the `woocommerce_shipping_cost_requires_address` options
185-
// group, since it is attached to the `woocommerce_enable_shipping_calc` option that gets removed if the
186-
// Cart block is in use.
187-
$calculations_title = '';
188-
189-
// Get Calculations title so we can add it to 'Hide shipping costs until an address is entered' option.
190-
foreach ( $settings as $setting ) {
191-
if ( 'woocommerce_enable_shipping_calc' === $setting['id'] ) {
192-
$calculations_title = $setting['title'];
193-
break;
194-
}
195-
}
196-
197-
// Add Calculations title to 'Hide shipping costs until an address is entered' option.
198-
foreach ( $settings as $index => $setting ) {
199-
if ( 'woocommerce_shipping_cost_requires_address' === $setting['id'] ) {
200-
$settings[ $index ]['title'] = $calculations_title;
201-
$settings[ $index ]['checkboxgroup'] = 'start';
202-
break;
203-
}
204-
}
205-
206-
$settings = array_filter(
207-
$settings,
208-
function( $setting ) {
209-
return ! in_array(
210-
$setting['id'],
211-
array(
212-
'woocommerce_enable_shipping_calc',
213-
),
214-
true
215-
);
216-
}
217-
);
218-
}
219-
220180
if ( CartCheckoutUtils::is_checkout_block_default() && $this->local_pickup_enabled ) {
221181
foreach ( $settings as $index => $setting ) {
222182
if ( 'woocommerce_shipping_cost_requires_address' === $setting['id'] ) {

0 commit comments

Comments
 (0)