Fix LightSpeed Cache + WooCommerce Caching Issues

If have any issues with LightSpeed Cache incorrectly caching WooCommerce data try this fix.

Go to LightSpeed Cache > Cache > Excludes tab

Under Do Not Cache Cookies, add:

woocommerce_items_in_cart

Save this, then clear all caches.

This solved a problem for me where the same product was being added twice, but with different attributes, and LightSpeed cache considered them the same product (making the quantity 2) rather than dealing with them as separate product lines.

How to change WooCommerce product gallery zoom image size

By default the WooCommerce product gallery zoom image size is very big.  This can cause the zoomed image to look distorted and too far from the original.

The cause is that WooCommerce selects the ‘full’ image size to use as the zoomed image.

Use the snippet below to the use the ‘medium’ image size as the zoom image.  ‘large’ will give a bigger zoomed image.

// Change the image size used for the WooCommerce product gallery image zoom
// 'medium' or 'large' are normally the best options
add_filter( 'woocommerce_gallery_full_size', function( $size ) {
  return 'medium';
} );

Send WooCommerce emails using code – useful for testing custom emails

If you need to test custom WooCommerce checkout email templates or functionality you don’t want to constantly be generating orders, or changing order statuses.

Instead use this snippet to send the emails until your code is working perfectly.

Just add it to your theme functions.php.  Be sure to set the $order_id and the $email_class if necessary.

add_action('init', 'send_wc_email');
function send_wc_email() {

// The order ID we're testing the email with
$order_id = 623;

// The email we want to send
$email_class = 'WC_Email_Customer_Processing_Order';

/*
Available emails are:
WC_Email_Customer_Note
WC_Email_Customer_Note
WC_Email_Customer_Completed_Order
WC_Email_Customer_Completed_Order
WC_Email_Customer_New_Account
WC_Email_Customer_New_Account
WC_Email_Customer_Reset_Password
WC_Email_Customer_Reset_Password
WC_Email_Customer_Processing_Order
WC_Email_Customer_Processing_Order
WC_Email_Customer_Invoice
WC_Email_Customer_Invoice
WC_Email_New_Order
*/

// Load the WooCommerce Emails
$wc_emails = new WC_Emails();
$emails = $wc_emails->get_emails();

// Select the email we want & trigger it to send
$new_email = $emails[$email_class];
$new_email->trigger($order_id);

// Show the email content
echo $new_email->get_content();
}

Latest from the blog

View All
Social media & sharing icons powered by UltimatelySocial