Creating a post on every page load.
-
Every time a page is loaded, the klaaviyo plugin creates as post for the saved cart. This is stored in in the woo commerce session, but the woo commerce session cookie is not sent to the client machine unless there is something in the cart. Since there is nothing in the cart, woo commerce doesn’t send the session cookie, the session is lost BUT klaaviyo created the post to store the cart.
This has resulted in 163,000 empty cart posts, which has caused a ton of other problems on the site.
Solution is the following five lines of code.
- wp-content/plugins/klaviyo-for-woocommerce/includes/wck-cart-functions.php -- index a8dfe6e..b2eaa1c 100644 @@ -71,6 +71,11 @@ function wck_save_or_update_cart() { } } + // don't create a post and the assorted crap if the cart doesn't have anything in it. + if($create_new_cart && WC()->cart->is_empty()) { + return; + } + if ( $create_new_cart ) { $cart_id = wp_insert_post( $cart_data, true );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Creating a post on every page load.’ is closed to new replies.