Untitled
unknown
plain_text
2 years ago
477 B
22
Indexable
add_filter( 'pws_add_rate', function ( array $rate, array $package, PWS_Shipping_Method $method ): array {
$is_on_backorder = false;
foreach ( $package['contents'] as $item ) {
/** @var WC_Product $product */
$product = $item['data'];
if ( $product->is_on_backorder() ) {
$is_on_backorder = true;
}
}
if ( $is_on_backorder ) {
$rate['cost'] *= 2;
}
return $rate;
}, 1000, 3 );Editor is loading...