2017-10-11 2 views
0

rest API로 장바구니에 제품을 업데이트 할 때 WooCommerce 장바구니 API에서 영구 장바구니를 업데이트하는 데 문제가 있습니다. 그것은 내 웹 사이트에 표시되지 않습니다. 나는이 API의 웹 사이트에서 제품을 추가하고 때 나는 제품을 얻을 것이다하지만 API에서 제품을 추가 할 때 웹 사이트 카트는 API 카트 제품에 우선Woocommerce Cart rest API

내 나머지 API 코드 :

if (sizeof(WC()->cart->get_cart()) > 0) { 
    $cart = WC()->instance()->cart; 
    if (woo_in_cart($product_id)) { 
     $cart_id  = $cart->generate_cart_id($product_id); 
     $cart_item_id = $cart->find_product_in_cart($cart_id); 
     $cart->set_quantity($cart_item_id, $quantity); 
    } else { 
     $cart->add_to_cart($product_id, $quantity); 
    } 

} else { 
    WC()->cart->add_to_cart($product_id, $quantity); 
} 
if (! empty($user_id)) { 
    $full_user_meta['cart'] = WC()->cart->get_cart();; 
    update_user_meta($user_id, '_woocommerce_persistent_cart_1', $full_user_meta); 
} 

답변

1

woocommerce_persistent_cart_1을 업데이트하는 것만으로는 사용자가wp_woocommerce_sessions 테이블에있는 세션 카트 데이터를 바꾸거나 업데이트해야합니다.

관련 문제