mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Add filter for shipping_needed
This commit is contained in:
parent
e1e0094398
commit
68c82a831d
1 changed files with 17 additions and 0 deletions
|
@ -289,6 +289,23 @@ class PurchaseUnitFactory {
|
|||
*/
|
||||
private function shipping_needed( Item ...$items ): bool {
|
||||
|
||||
/**
|
||||
* If you are returning false from this filter, do not forget to also set
|
||||
* shipping_preference to 'NO_SHIPPING', otherwise PayPal will return an error.
|
||||
*
|
||||
* @see ShippingPreferenceFactory::from_state() for
|
||||
* the 'woocommerce_paypal_payments_shipping_preference' filter.
|
||||
*/
|
||||
$shipping_needed = apply_filters(
|
||||
'woocommerce_paypal_payments_shipping_needed',
|
||||
null,
|
||||
$items
|
||||
);
|
||||
|
||||
if ( is_bool( $shipping_needed ) ) {
|
||||
return $shipping_needed;
|
||||
}
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
if ( $item->category() !== Item::DIGITAL_GOODS ) {
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue