Skip to content

Instantly share code, notes, and snippets.

View gareth-gillman's full-sized avatar

gareth-gillman

View GitHub Profile
@GeekPress
GeekPress / cache-woo-get-refreshed-fragment-request.php
Last active July 25, 2019 09:58
Cache WooCommerce Get Refreshed Fragment Request
<?php
if ( isset( $_GET['wc-ajax'] ) && 'get_refreshed_fragments' === $_GET['wc-ajax'] && ( !isset( $_COOKIE['woocommerce_cart_hash'] ) || empty( $_COOKIE['woocommerce_cart_hash'] ) ) && ( !isset( $_COOKIE['woocommerce_items_in_cart'] ) || empty( $_COOKIE['woocommerce_items_in_cart'] ) ) ) {
$data = get_transient( 'rocket_get_refreshed_fragments_cache' );
if ( ! empty( $data ) ) {
$data = json_decode( $data );
wp_send_json( $data );
}
ob_start();