Clear stale Entries on load

Although stale entries are cleared via the woocommerce_cleanup_sessions cron schedule that runs twice daily, this snippet will clear the stale entries on site load.

Code

Filename: gspc-clear-stale-entries-on-load.php

<?php
/**
 * Gravity Shop // Product Configurator // Clear stale Entries on load
 * https://gravitywiz.com/documentation/gravity-shop-product-configurator/
 *
 * Although stale entries are cleared via the `woocommerce_cleanup_sessions` cron schedule that runs twice daily,
 * this snippet will clear the stale entries on site load.
 */

add_action( 'woocommerce_set_cart_cookies', function( $set ) {
	if ( ! $set && class_exists( 'GS_Product_Configurator\Entry_Lifecycle' ) ) {
		$entry_lifecycle = new GS_Product_Configurator\Entry_Lifecycle();
		$entry_lifecycle->cleanup_stale_entries();
	}
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.