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:

functions.php
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.

  1. WooCommerce icon 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
  2. WooCommerce PayPal Payments icon WooCommerce PayPal Payments700,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) modules/ppcp-applepay/src/Assets/ApplePayButton.php:369
  3. WooCommerce Stripe Payment Gateway icon WooCommerce Stripe Payment Gateway700,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/payment-methods/class-wc-stripe-express-checkout-helper.php:1725
  4. Mollie Payments for WooCommerce icon Mollie Payments for WooCommerce100,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) src/Buttons/ApplePayButton/AppleAjaxRequests.php:354
  5. WooCommerce Square icon WooCommerce Square80,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/Gateway/Digital_Wallet.php:796
  6. FunnelKit Payment Gateway for Stripe WooCommerce icon FunnelKit Payment Gateway for Stripe WooCommerce20,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/traits/wc-smart-button-functions.php:883
  7. Airwallex Online Payments Gateway icon Airwallex Online Payments Gateway10,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/Controllers/OrderController.php:872
  8. Payment Gateway of Stripe for WooCommerce icon Payment Gateway of Stripe for WooCommerce7,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/class-stripe-payment-request-button.php:642
  9. Revolut Gateway for WooCommerce icon Revolut Gateway for WooCommerce7,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/traits/wc-revolut-express-checkout-helper-trait.php:90
  10. AppMySite icon AppMySite7,000+ installs apply_filters( 'woocommerce_cart_shipping_packages', WC()->cart->get_shipping_packages() ) includes/class-ams-rest-routes.php:1237
  11. YITH WooCommerce Subscription icon 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
  12. payever Checkout icon payever Checkout800+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/widget/class-payever-widget-quote-helper.php:86
  13. HyperPay Payments icon HyperPay Payments600+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) src/App/HyperpayExpressBlock.php:390
  14. Square Sync for WooCommerce icon Square Sync for WooCommerce200+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/Payments/WC_SquareSync_Gateway.php:872
  15. Autify Digital Lloyds® Gateway for WooCommerce icon 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
  16. FunnelKit Payment Gateway for Square WooCommerce icon FunnelKit Payment Gateway for Square WooCommerce100+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/smartbuttons.php:632
  17. Yandex pay icon Yandex pay100+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/class-wc-one-click-checkout.php:201
  18. BlueSnap Payment Gateway for WooCommerce icon BlueSnap Payment Gateway for WooCommerce100+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/class-wc-bluesnap-payment-request.php:909
  19. Shoparize Partner icon Shoparize Partner90+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) shoparize-product-api.php:173
  20. Monta Checkout icon Monta Checkout50+ installs do_action( 'woocommerce_cart_shipping_packages' ) src/Packing.php:930
  21. SMM API icon 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
  22. Marketing 360® Payments for WooCommerce icon Marketing 360® Payments for WooCommerce30+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/payment-methods/class-wc-stripe-payment-request.php:1201
  23. Foolosi Subscription for WooCommerce icon 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
  24. Buyte icon Buyte10+ installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) buyte.php:602
  25. PayEngine Payment Gateway for WooCommerce icon PayEngine Payment Gateway for WooCommerceFewer than 10 installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/controller/class-payengine-apple-pay.php:229
  26. HSBC Open Payments icon HSBC Open PaymentsFewer than 10 installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/widget/class-hsbc-widget-quote-helper.php:86
  27. Zinia icon ZiniaFewer than 10 installs apply_filters( 'woocommerce_cart_shipping_packages', $packages ) includes/widget/class-wc-zinia-widget-quote-helper.php:86
  28. PayRivet Payments with Stripe for WooCommerce icon 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
  29. ZERTI icon 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.