WordPress filter hook
woocommerce_cart_shipping_packages
Defined by WooCommerce and fired by 28 plugins in total, running on 8.6M+ sites between them.
“Filters the shipping packages for the cart.”
How to use woocommerce_cart_shipping_packages
It's a filter: your callback receives the value, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'woocommerce_cart_shipping_packages', function( $packages ) {
// Change $packages here.
return $packages;
}, 10, 1 );Argument names come from WooCommerce PayPal Payments's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
28 plugins that fire woocommerce_cart_shipping_packages
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WooCommerce7+ million installs
apply_filters( 'woocommerce_cart_shipping_packages', array( array( 'contents' => $this->get_items_needing_shipping(), 'contents_cost' => array_sum( wp_list_pluck( $this->get_items_needing_shipping(), 'line_total' ) ), 'applied_coupons' => $this->get_applied_coupons(), 'user' => array( 'ID' => get_current_user_id(), ), 'destination' => array( 'country' => $this->get_customer()->get_shipping_country(), 'state' => $this->get_customer()->get_shipping... )includes/class-wc-cart.php:1760 -
WooCommerce PayPal Payments700,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )modules/ppcp-applepay/src/Assets/ApplePayButton.php:369 -
WooCommerce Stripe Payment Gateway700,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/payment-methods/class-wc-stripe-express-checkout-helper.php:1725 -
Mollie Payments for WooCommerce100,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )src/Buttons/ApplePayButton/AppleAjaxRequests.php:354 -
WooCommerce Square80,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/Gateway/Digital_Wallet.php:796 -
FunnelKit Payment Gateway for Stripe WooCommerce20,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/traits/wc-smart-button-functions.php:883 -
Airwallex Online Payments Gateway10,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/Controllers/OrderController.php:872 -
Payment Gateway of Stripe for WooCommerce7,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/class-stripe-payment-request-button.php:642 -
Revolut Gateway for WooCommerce7,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/traits/wc-revolut-express-checkout-helper-trait.php:90 -
AppMySite7,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', WC()->cart->get_shipping_packages() )includes/class-ams-rest-routes.php:1237 -
YITH WooCommerce Subscription6,000+ installs
apply_filters( 'woocommerce_cart_shipping_packages', array( 0 => array( 'contents' => $new_cart->get_cart(), 'contents_cost' => isset( $new_cart->cart_contents[ $new_cart_item_key ]['line_total'] ) ? $new_cart->cart_contents[ $new_cart_item_key ]['line_total'] : 0, 'destination' => $shipping['destination'], ), ) )includes/class-ywsbs-subscription-order.php:235 -
payever Checkout800+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/widget/class-payever-widget-quote-helper.php:86 -
HyperPay Payments600+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )src/App/HyperpayExpressBlock.php:390 -
Square Sync for WooCommerce200+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/Payments/WC_SquareSync_Gateway.php:872 -
Autify Digital Lloyds® Gateway for WooCommerce100+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/controller/wallet/class-autify-lloyds-process-apple-pay-order.php:228 -
FunnelKit Payment Gateway for Square WooCommerce100+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/smartbuttons.php:632 -
Yandex pay100+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/class-wc-one-click-checkout.php:201 -
BlueSnap Payment Gateway for WooCommerce100+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/class-wc-bluesnap-payment-request.php:909 -
Shoparize Partner90+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )shoparize-product-api.php:173 -
Monta Checkout50+ installs
do_action( 'woocommerce_cart_shipping_packages' )src/Packing.php:930 -
SMM API40+ installs
apply_filters( 'woocommerce_cart_shipping_packages', array( 0 => array( 'contents' => $new_cart->get_cart(), 'contents_cost' => isset( $new_cart->cart_contents[ $new_cart_item_key ]['line_total'] ) ? $new_cart->cart_contents[ $new_cart_item_key ]['line_total'] : 0, 'applied_coupons' => $new_cart->applied_coupons, 'destination' => $shipping['destination'], ), ) )includes/class.smms-wc-subscription-order.php:220 -
Marketing 360® Payments for WooCommerce30+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/payment-methods/class-wc-stripe-payment-request.php:1201 -
Foolosi Subscription for WooCommerce10+ installs
apply_filters( 'woocommerce_cart_shipping_packages', array( 0 => array( 'contents' => $new_cart->get_cart(), 'contents_cost' => isset( $new_cart->cart_contents[ $new_cart_item_key ]['line_total'] ) ? $new_cart->cart_contents[ $new_cart_item_key ]['line_total'] : 0, 'applied_coupons' => $new_cart->applied_coupons, 'destination' => $shipping['destination'], ), ) )includes/class.foloosi-wc-subscription-order.php:198 -
Buyte10+ installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )buyte.php:602 -
PayEngine Payment Gateway for WooCommerceFewer than 10 installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/controller/class-payengine-apple-pay.php:229 -
HSBC Open PaymentsFewer than 10 installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/widget/class-hsbc-widget-quote-helper.php:86 -
ZiniaFewer than 10 installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/widget/class-wc-zinia-widget-quote-helper.php:86 -
PayRivet Payments with Stripe for WooCommerceFewer than 10 installs
apply_filters( 'woocommerce_cart_shipping_packages', $packages )includes/payment-methods/class-wc-stripe-express-checkout-helper.php:1700 -
ZERTIFewer than 10 installs
apply_filters( 'woocommerce_cart_shipping_packages', [$package] )includes/zerti-shop-order-create.php:1121
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.