Skip to content

Commit e1e0094

Browse files
committed
Add filter for shipping preference
1 parent f3598eb commit e1e0094

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

modules/ppcp-api-client/src/Factory/ShippingPreferenceFactory.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ public function from_state(
3333
?WC_Cart $cart = null,
3434
string $funding_source = ''
3535
): string {
36+
/**
37+
* If you are using this filter to set 'NO_SHIPPING', you may also want to disable sending
38+
* shipping fields completely.
39+
*
40+
* @see PurchaseUnitFactory::shipping_needed() for
41+
* the woocommerce_paypal_payments_shipping_needed filter.
42+
*
43+
* @see ExperienceContext for SHIPPING_PREFERENCE_* constants.
44+
* @see https://developer.paypal.com/serversdk/php/models/enumerations/shipping-preference/
45+
*/
46+
$shipping_preference = apply_filters(
47+
'woocommerce_paypal_payments_shipping_preference',
48+
null,
49+
$purchase_unit,
50+
$context,
51+
$cart,
52+
$funding_source
53+
);
54+
55+
if ( is_string( $shipping_preference ) ) {
56+
return $shipping_preference;
57+
}
58+
3659
$contains_physical_goods = $purchase_unit->contains_physical_goods();
3760
if ( ! $contains_physical_goods ) {
3861
return ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING;

0 commit comments

Comments
 (0)