How to prevent those PHP variables from being cached on WordPress?

Page caching generates a static HTML version of the page so IP geolocation occurs on the first rendering and is not triggered on subsequent renderings – your use case is not compatible with W3 Total Cache’s page caching. It’s possible to accomplish what you are trying to accomplish with page caching, however, you would need … Read more

Accessing parameters when adding filter

When you call add_filter(), set the fourth parameter to 3 (which is the number of parameters accepted by the callback function which in your case is change_rating_output()), and then change your change_rating_output() function so that it accepts the $rating and $count parameters: add_filter(‘woocommerce_product_get_rating_html’, ‘change_rating_output’, 10, 3); function change_rating_output($html, $rating, $count){ // Now do what you … Read more

Move WooCommerce product tabs out of the tabs [closed]

It turned out that woocommerce_get_template() was deprecated and replaced by wc_get_template(). I solved this by adding this to my functions.php. add_action( ‘woocommerce_after_single_product_summary’, ‘removing_product_tabs’, 2 ); function removing_product_tabs(){ remove_action(‘woocommerce_after_single_product_summary’,’woocommerce_output_product_data_tabs’, 10 ); add_action(‘woocommerce_after_single_product_summary’,’get_product_tab_templates_displayed’, 10 ); } function get_product_tab_templates_displayed() { wc_get_template( ‘single-product/tabs/description.php’ ); wc_get_template( ‘single-product/tabs/additional-information.php’ ); comments_template(); }

Woocommerce add_to_cart non-register visitor not working

I did two tests on my dev site add_action( “wp_loaded”, function() { var_dump(WC()->cart->add_to_cart(1353)); }); and add_action( “wp_footer”, function() { var_dump(WC()->cart->add_to_cart(1353)); }); Both var_dump a hash, but only the first one actually adds a product to the cart, the second prints the hash but does not add anything. What is happening is that in the second … Read more

Move add to cart in Woocommerce

You can change the priority/order by removing and re-adding the parts you want the position changed – like this: remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 ); add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_add_to_cart’, 10 ); Drop this piece of code into your functions.php to take effect.

Changing Woocommerce flat rate every nth number of items

To change “Flat rate” shipping cost based on cart items quantity count that belongs to a specific shipping class, you will need something a bit different: add_filter( ‘woocommerce_package_rates’, ‘progressive_shipping_cost_based_shipping_class_quantity_steps’, 10, 2 ); function progressive_shipping_cost_based_shipping_class_quantity_steps( $rates, $package ) { // HERE Bellow your settings $shipping_class = “large-shipping”; // The shipping class ID $qty_step = 3; // … Read more