UWooCommerce – add cart discount programmatically?

I haven’t applied any discounts like that before, but have done it with ‘fees’ a lot. Adding a fee is quite easy: function custom_wc_add_fee() { WC()->cart->add_fee( ‘Fee’, -10 ); } add_action( ‘woocommerce_cart_calculate_fees’,’custom_wc_add_fee’ ); (or if you want a plugin solution, I created this plugin: https://aceplugins.com/plugin/woocommerce-advanced-fees/)

Best Practice – Customise a WooCommerce+WordPress Templates

The best practice for editing a Woocommerce theme is similar to WordPress as you should use Hooks and Filters when possible. https://docs.woothemes.com/document/introduction-to-hooks-actions-and-filters/ But if you do need to edit a template Woocommerce outlines this on their website as well: https://docs.woothemes.com/document/template-structure/ You just need to make the template upgrade safe by copying the template to your … Read more

Debugging why featured images have stopped showing in WooCommerce on the homepage [closed]

These are WooCommerce 3.x instructions only. That thread on GitHub (https://github.com/woocommerce/woocommerce/issues/14914#issuecomment-299714488) was updated by one of the Woo devs and he provided an example loop and explained what is happening: Featured was meta in 2.6, but is a taxonomy (for performance!) in 3.0 – so adjust queries to use tax_query instead of meta_query accordingly. To … Read more

woocommerce – customise notice error in checkout page

The message itself is not filterable, so the simplest way to change it is to basically ‘translate’ it using the gettext filter: function wpse_284393_checkout_message( $translated_text, $text, $domain ) { if ( $domain !== ‘woocommerce’ ) { return $translated_text; } if ( $text=”Unfortunately <strong>we do not ship %s</strong>. Please enter an alternative shipping address.” ) { … Read more