mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Fix more than 1 shipping option selected problem
This commit is contained in:
parent
1de6039d5b
commit
c011ce659f
1 changed files with 2 additions and 5 deletions
|
@ -50,9 +50,7 @@ class ShippingOptionFactory {
|
||||||
$cart->calculate_shipping();
|
$cart->calculate_shipping();
|
||||||
|
|
||||||
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
|
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
|
||||||
if ( ! is_array( $chosen_shipping_methods ) ) {
|
$chosen_shipping_method = $chosen_shipping_methods[0] ?? false;
|
||||||
$chosen_shipping_methods = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$packages = WC()->shipping()->get_packages();
|
$packages = WC()->shipping()->get_packages();
|
||||||
$options = array();
|
$options = array();
|
||||||
|
@ -62,11 +60,10 @@ class ShippingOptionFactory {
|
||||||
if ( ! $rate instanceof \WC_Shipping_Rate ) {
|
if ( ! $rate instanceof \WC_Shipping_Rate ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$options[] = new ShippingOption(
|
$options[] = new ShippingOption(
|
||||||
$rate->get_id(),
|
$rate->get_id(),
|
||||||
$rate->get_label(),
|
$rate->get_label(),
|
||||||
in_array( $rate->get_id(), $chosen_shipping_methods, true ),
|
$rate->get_id() === $chosen_shipping_method,
|
||||||
new Money(
|
new Money(
|
||||||
(float) $rate->get_cost(),
|
(float) $rate->get_cost(),
|
||||||
get_woocommerce_currency()
|
get_woocommerce_currency()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue