Cart Data - Filter Hook References

Modified on Thu, 9 Feb, 2023 at 11:49 PM

This is simply a list of cart data-related filter hooks included in the WooCommerce Catalog Mode - Pricing, Enquiry Forms & Promotions files. This list also includes the supported parameters and example codes.


wmodes/get-cart-item

  • Parameters:
  • $cart_item array()
  • $raw_cart_item array()
  • $contex string


Example Codes:

function custom_get_cart_item( $cart_item, $raw_cart_item, $contex ) {

    //add your custom code here
    return $cart_item;
}

add_filter( 'wmodes/get-cart-item', 'custom_get_cart_item', 10, 3 );

wmodes/get-cart-totals

  • Parameters:
  • $totals array()
  • $raw_totals array()
  • $contex string


Example Codes:

function custom_get_cart_totals( $totals, $raw_totals, $contex ) {

    //add your custom code here
    return $totals;
}

add_filter( 'wmodes/get-cart-totals', 'custom_get_cart_totals', 10, 3 );

wmodes/get-cart-applied-coupons

  • Parameters:
  • $applied_coupons array()
  • $raw_applied_coupons array()
  • $contex string


Example Codes:

function custom_get_cart_applied_coupons( $applied_coupons, $raw_applied_coupons, $contex ) {

    //add your custom code here
    return $applied_coupons;
}

add_filter( 'wmodes/get-cart-applied-coupons', 'custom_get_cart_applied_coupons', 10, 3 );

wmodes/get-cart-shipping

  • Parameters:
  • $shipping array()
  • $raw_shipping array()
  • $contex string


Example Codes:

function custom_get_cart_shipping( $shipping, $raw_shipping, $contex ) {

    //add your custom code here
    return $shipping;
}

add_filter( 'wmodes/get-cart-shipping', 'custom_get_cart_shipping', 10, 3 );

wmodes/get-cart-payment-method-id

  • Parameters:
  • $payment_method_id array()
  • $raw_payment_method_id array()
  • $contex string


Example Codes:

function custom_get_cart_payment_method_id( $payment_method_id, $raw_payment_method_id, $contex ) {

    //add your custom code here
    return $payment_method_id;
}

add_filter( 'wmodes/get-cart-payment-method-id', 'custom_get_cart_payment_method_id', 10, 3 );

wmodes/get-cart-customer

  • Parameters:
  • $customer array()
  • $raw_customer array()


Example Codes:

function custom_get_cart_customer( $customer, $raw_customer ) {

    //add your custom code here
    return $customer;
}

add_filter( 'wmodes/get-cart-customer', 'custom_get_cart_customer', 10, 2 );

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article