mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Merge pull request #3169 from woocommerce/PCP-4256-shipping-callback-not-loading-despite-being-enabled
Shipping Callback not loading despite being enabled (4256)
This commit is contained in:
commit
9f417f11be
4 changed files with 9 additions and 26 deletions
|
@ -28,13 +28,6 @@ return array(
|
|||
);
|
||||
},
|
||||
'blocks.method' => static function ( ContainerInterface $container ): PayPalPaymentMethod {
|
||||
/**
|
||||
* Cart instance; might be null, esp. in customizer or in Block Editor.
|
||||
*
|
||||
* @var null|WC_Cart $cart
|
||||
*/
|
||||
$cart = WC()->cart;
|
||||
|
||||
return new PayPalPaymentMethod(
|
||||
$container->get( 'blocks.url' ),
|
||||
$container->get( 'ppcp.asset-version' ),
|
||||
|
@ -53,7 +46,6 @@ return array(
|
|||
$container->get( 'wcgateway.place-order-button-text' ),
|
||||
$container->get( 'wcgateway.place-order-button-description' ),
|
||||
$container->get( 'wcgateway.all-funding-sources' ),
|
||||
$cart && $cart->needs_shipping()
|
||||
);
|
||||
},
|
||||
'blocks.advanced-card-method' => static function( ContainerInterface $container ): AdvancedCardPaymentMethod {
|
||||
|
|
|
@ -23,7 +23,7 @@ use WooCommerce\PayPalCommerce\Button\Endpoint\RequestData;
|
|||
*/
|
||||
class UpdateShippingEndpoint implements EndpointInterface {
|
||||
const ENDPOINT = 'ppc-update-shipping';
|
||||
const WC_STORE_API_ENDPOINT = '/wp-json/wc/store/cart/';
|
||||
const WC_STORE_API_ENDPOINT = '/wp-json/wc/store/v1/cart/';
|
||||
|
||||
/**
|
||||
* The Request Data Helper.
|
||||
|
|
|
@ -130,13 +130,6 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
*/
|
||||
private $all_funding_sources;
|
||||
|
||||
/**
|
||||
* Whether shipping details must be collected during checkout; i.e. paying for physical goods?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $need_shipping;
|
||||
|
||||
/**
|
||||
* Assets constructor.
|
||||
*
|
||||
|
@ -155,7 +148,6 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
* @param string $place_order_button_text The text for the standard "Place order" button.
|
||||
* @param string $place_order_button_description The text for additional "Place order" description.
|
||||
* @param array $all_funding_sources All existing funding sources for PayPal buttons.
|
||||
* @param bool $need_shipping Whether shipping details are required for the purchase.
|
||||
*/
|
||||
public function __construct(
|
||||
string $module_url,
|
||||
|
@ -172,8 +164,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
bool $use_place_order,
|
||||
string $place_order_button_text,
|
||||
string $place_order_button_description,
|
||||
array $all_funding_sources,
|
||||
bool $need_shipping
|
||||
array $all_funding_sources
|
||||
) {
|
||||
$this->name = PayPalGateway::ID;
|
||||
$this->module_url = $module_url;
|
||||
|
@ -191,7 +182,6 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
$this->place_order_button_text = $place_order_button_text;
|
||||
$this->place_order_button_description = $place_order_button_description;
|
||||
$this->all_funding_sources = $all_funding_sources;
|
||||
$this->need_shipping = $need_shipping;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,6 +248,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
&& $this->settings_status->is_smart_button_enabled_for_location( $script_data['context'] ?? 'block-checkout' );
|
||||
$place_order_enabled = ( $this->use_place_order || $this->add_place_order_method )
|
||||
&& ! $this->subscription_helper->cart_contains_subscription();
|
||||
$cart = WC()->cart;
|
||||
|
||||
return array(
|
||||
'id' => $this->gateway->id,
|
||||
|
@ -284,7 +275,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
),
|
||||
),
|
||||
'scriptData' => $script_data,
|
||||
'needShipping' => $this->need_shipping,
|
||||
'needShipping' => $cart && $cart->needs_shipping(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue