mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Testing shipping fields updating ApplePay addresses on checkout page
This commit is contained in:
parent
e52acf3c60
commit
d49eb60358
4 changed files with 98 additions and 21 deletions
|
@ -79,17 +79,49 @@ class CartScriptParamsEndpoint implements EndpointInterface {
|
|||
$shop_country_code = $base_location['country'] ?? '';
|
||||
$currency_code = get_woocommerce_currency();
|
||||
|
||||
|
||||
$calculated_packages = WC()->shipping->calculate_shipping(
|
||||
WC()->cart->get_shipping_packages()
|
||||
);
|
||||
|
||||
$shipping_packages = array();
|
||||
|
||||
foreach ( $calculated_packages[0]['rates'] as $rate ) {
|
||||
$rate_cost = $rate->get_cost();
|
||||
|
||||
/**
|
||||
* The shipping rate.
|
||||
*
|
||||
* @var \WC_Shipping_Rate $rate
|
||||
*/
|
||||
$shipping_packages[] = array(
|
||||
'id' => $rate->get_id(),
|
||||
'label' => $rate->get_label(),
|
||||
'cost' => (float) $rate_cost,
|
||||
'cost_str' => ( new Money( (float) $rate_cost, $currency_code ) )->value_str(),
|
||||
'description' => html_entity_decode(
|
||||
wp_strip_all_tags(
|
||||
wc_price( (float) $rate->get_cost(), array( 'currency' => get_woocommerce_currency() ) )
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'url_params' => $script_data['url_params'],
|
||||
'button' => $script_data['button'],
|
||||
'messages' => $script_data['messages'],
|
||||
'amount' => WC()->cart->get_total( 'raw' ),
|
||||
'url_params' => $script_data['url_params'],
|
||||
'button' => $script_data['button'],
|
||||
'messages' => $script_data['messages'],
|
||||
'amount' => WC()->cart->get_total( 'raw' ),
|
||||
|
||||
'total' => $total,
|
||||
'total_str' => ( new Money( $total, $currency_code ) )->value_str(),
|
||||
'currency_code' => $currency_code,
|
||||
'country_code' => $shop_country_code,
|
||||
'total' => $total,
|
||||
'total_str' => ( new Money( $total, $currency_code ) )->value_str(),
|
||||
'currency_code' => $currency_code,
|
||||
'country_code' => $shop_country_code,
|
||||
|
||||
'chosen_shipping_methods' => WC()->session->get( 'chosen_shipping_methods' ),
|
||||
'shipping_packages' => $shipping_packages
|
||||
)
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue