Table of Contents
WooCommerce has made it really easy to customize our shop with the help of various hooks. WooCommerce has placed different hooks on the product page, cart page & checkout page so that we can add our content on those pages.
In this post, we will look at the various WooCommerce cart page hooks. Different hooks can be used based on the position of the content you want to place on the cart page.
woocommerce_proceed_to_checkout Proceed to Checkout
The woocommerce_before_cart hook is placed before the cart form. It means that the function we hook into this action will be executed before the start of the cart form.
The woocommerce_cart_actions hook is used to add custom actions or buttons placed at specific points you wish under the cart totals on the WooCommerce cart page. This hook is typically used to indicate custom actions such as ‘Update cart’ or ‘Add a coupon’ presented as a link or a button.
The woocommerce_before_cart_table hook is placed inside the cart form but before the start of the cart table.
The woocommerce_before_cart_contents hook is placed inside the cart table after the title of the columns. This hook can be used if you want to display any message inside the table.
Increase WooCommerce Store Sales
"Abandoned cart pro is worth every penny. We have successfully recovered about 17k just this month in sales. The extra benefit of exporting and diagnosing potential sales and areas where we need improvement are immense. An extra special thanks to David Katzner and the developers for their attention to some custom requests we had asked for." - Kenny Rhoads at MultiTable
The woocommerce_cart_contents hook is placed inside the table and above the ‘Update Cart’ button.
The woocommerce_cart_coupon hook is placed below the ‘Apply Coupon’ button.
The woocommerce_after_cart_contents hook is placed after the coupon and inside the cart table.
The woocommerce_after_cart_table hook is placed outside the cart table but inside the cart form.
The woocommerce_cart_collaterals hook is placed below the cart table and above the cart totals.
The woocommerce_before_cart_totals hook can be found in the file cart-totals.php. It is placed before the cart subtotal.
The woocommerce_cart_totals_before_shipping hook is inside the cart-totals.php file. It is placed above the shipping fields in the cart totals. If we add our function to this hook, it will get executed if the cart has shipping enabled.
The woocommerce_before_shipping_calculator hook is placed above the ‘Calculate Shipping’ option in the cart totals and below the shipping options.
The woocommerce_after_shipping_calculator hook is placed after the ‘Calculate Shipping’ options and above the total.
The woocommerce_cart_totals_after_shipping hook is similar to woocommerce_cart_totals_before_shipping but it is placed after the shipping fields.
The woocommerce_after_shippping_rate hook is placed in the ‘shipping options’ under the cart totals. This hook will allow you to modify or display information related to shipping rates.
The woocommerce_cart_totals_before_order_total hook can be found in cart-totals.php file in WooCommerce. It is placed just above the totals field in the cart.
The woocommerce_cart_totals_after_order_total action hook is also created in cart-totals.php file of WooCommerce. It is placed just below the totals field on the cart page.
The woocommerce_after_cart_totals hook is placed in the cart-totals.php file in WooCommerce below the ‘Proceed to Checkout’ button.
The woocommerce_cart_is_empty hook is placed on the empty cart page. This hook is triggered when the customer visits the cart page and the cart is empty. Using this hook you can
add additional text below the ‘Your cart is currently empty!’ text.
The woocommerce_proceed_to_checkout hook can be found in cart-totals.php file in the WooCommerce. The ‘Proceed to Checkout’ button is also placed using this hook inside the ‘wc-template-hooks.php‘ file.
The woocommerce_after_cart hook is placed at the end of the cart, outside the cart table.