1

I want to add a custom column for "Installation Charges" inside cart items. This is going to be different installation charges for every product. I can pass that to cart using woocommerce_add_cart_item_data action hook. But how do I add the separate column to show these installation charges in cart?

Attached is a screenshot mockup of how it needs to be built.

enter image description here

1 Answer 1

2

Overwrite the WooCommerce template in your theme. The documentation for this can be found at https://docs.woocommerce.com/document/template-structure/

The file you're looking to overwrite is wp-content/woocommerce/templates/cart/cart.php

4
  • Thanks Jeffrey but I am actually working on a plugin, so not allowed to touch the theme files. Is there some action or filter hooks to achieve this? Commented Apr 19, 2017 at 9:25
  • Hmm... Based on the code of that file, there are not available hooks to alter the table columns. You could take a look at this old article from 2012 skyverge.com/blog/… basically meaning that themes can still override your file but if you tell them that you've done so in the plugin they can copy that instead and it should all be fine.
    – Jebble
    Commented Apr 19, 2017 at 9:29
  • I just tried the method from old article but theme is already overriding the template files, so it's not working. Commented Apr 19, 2017 at 10:17
  • Well with that same method you can take away the check for WC templates in the theme and force it to only check in your plugin but then no one will use your plugin. It's simply not gonna happen ;)
    – Jebble
    Commented Apr 19, 2017 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.