Skip to content
Advertisement

How to modify woocommerce_before_cart action

I’m trying to make my woocommerce cart template display as a full 12 column layout.

The existing layout is using bootstrap’s col-sm-8 column. I need to change it to col-sm-12.

<main class="main col-sm-8" role="main">
  <div class="page-header">
   <h1>Cart</h1>
  </div>

<div class="woocommerce">...</div>

<div class="woocommerce-info">...</div>

<div class="cart-collaterals">
    // shipping code etc.
</div>
</main>

I checked out the relevant woo-templates shown here, and copied the cart.php template into my theme to override. However, it looks like I need to modify the woocommerce_before_cart action to change the <main> layout and insert the col-sm-12 class. I found the relevant actions on this woocommerce page.

I can see from the cart.php template the action called before the <form> element as shown below:

global $woocommerce;

wc_print_notices();

do_action( 'woocommerce_before_cart' ); ?>

<form action="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" method="post">

<?php do_action( 'woocommerce_before_cart_table' ); ?>

<table class="shop_table cart" cellspacing="0">enter code here

I’m new to php, my question is how do I modify the output of this action so I can change the layout to 12 columns?

Advertisement

Answer

Woocommerce inserts the content in cart.php into page.php in the root of your theme. 🙂

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement