Prevent cart hash becoming invalidated due to product/post data
This commit is contained in:
parent
21c5513526
commit
b729480838
|
@ -157,7 +157,7 @@ class WC_AJAX {
|
|||
'div.widget_shopping_cart_content' => '<div class="widget_shopping_cart_content">' . $mini_cart . '</div>'
|
||||
)
|
||||
),
|
||||
'cart_hash' => apply_filters( 'woocommerce_add_to_cart_hash', WC()->cart->get_cart() ? md5( json_encode( WC()->cart->get_cart() ) ) : '', WC()->cart->get_cart() )
|
||||
'cart_hash' => apply_filters( 'woocommerce_add_to_cart_hash', WC()->cart->get_cart_for_session() ? md5( json_encode( WC()->cart->get_cart_for_session() ) ) : '', WC()->cart->get_cart_for_session() )
|
||||
);
|
||||
|
||||
wp_send_json( $data );
|
||||
|
|
|
@ -186,7 +186,7 @@ class WC_Cart {
|
|||
private function set_cart_cookies( $set = true ) {
|
||||
if ( $set ) {
|
||||
wc_setcookie( 'woocommerce_items_in_cart', 1 );
|
||||
wc_setcookie( 'woocommerce_cart_hash', md5( json_encode( $this->get_cart() ) ) );
|
||||
wc_setcookie( 'woocommerce_cart_hash', md5( json_encode( $this->get_cart_for_session() ) ) );
|
||||
} elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) {
|
||||
wc_setcookie( 'woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS );
|
||||
wc_setcookie( 'woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS );
|
||||
|
@ -691,8 +691,7 @@ class WC_Cart {
|
|||
*
|
||||
* @return array contents of the cart
|
||||
*/
|
||||
private function get_cart_for_session() {
|
||||
|
||||
public function get_cart_for_session() {
|
||||
$cart_session = array();
|
||||
|
||||
if ( $this->get_cart() ) {
|
||||
|
|
Loading…
Reference in New Issue