2017-01-12 3 views
-2

내가 woocommerce_before_calculate_totals에게 훅을 사용하고과는 완벽하게 작동 카트 woocommerce 에 나는 지금은 제품이있는 경우에만 장바구니에 사용자 정의 가격를 추가 할 사용자 정의 가격을 추가해야합니다 특정 카테고리에서. 도움이 필요하십니까Woocommerce 카테고리 점검과 사용자 정의 가격을 추가

add_action('woocommerce_before_calculate_totals', 'add_custom_price'); 
    function add_custom_price($cart_object) { 
     $custom_price = 50; // This will be your custome price 
     foreach ($cart_object->cart_contents as $key => $value) { 
      $value['data']->price = $custom_price; 
     } 

    } 

    } 

도와 주실 수 있습니까? 코드 아래

답변

0

시도 :

add_action('woocommerce_before_calculate_totals', 'add_custom_price'); 
function add_custom_price($cart_object) { 
    foreach ($cart_object->cart_contents as $key => $value) { 
     $productId = $value['data']->id; 
     if (has_term('category-to-becheck', 'product_cat', $productId)) { 
     { 
      $c_price = $value['data']->price; 
      $your_custom_price = // 
      $value['data']->price = $value['data']->price + $your_custom_price; 
     } 
    } 
} 
} 
+0

감사 @Ash 파텔은 내가 미만 명성을 가지고 있기 때문에 나는 투표를 할 수없는 매력 정말 감사 형제 .. – ahsandreamwarrior

+0

처럼 일하지만 당신의 대답은 허용됩니다 감사 형제. – ahsandreamwarrior