2017-05-06 1 views
1

PrestaShop 버전 할인 작동하지 않습니다와 나는 cartrule 프로그래밍 안녕하세요 처음에는이 지역 사회 내 성경이라고 말하고 싶은 1.7

지금 내 질문에 대한 및 대한 할인 혜택에 노력하고, 많은 빚을 대단히 감사합니다

이 코드는 성공적으로 제품에 대한 할인 규칙을 만듭니다
 $context = Context::getContext(); 
    $cod_prod = Tools::getValue('id_data'); 
    $qty = Tools::getValue('qty'); 
    $descuento = Tools::getValue('descuento'); 

    $time_original = strtotime(date("Y-m-d H:i:s")); 
    $time_add  = $time_original + (3600*24); 

    $r = new CartRule(); 
    $r->name = array(1=>"descuento".$context->cookie->id_customer.date("Ymd_His")); 
    $r->id_customer = $context->cookie->id_customer; 
    $r->date_from = date("Y-m-d H:i:s"); 
    $r->date_to = date("Y-m-d H:i:s", $time_add); 
    $r->description = "desc"; 
    $r->quantity = $qty; 
    $r->quantity_per_user = $qty; 
    $r->priority = 1; 
    $r->partial_use = 1; 
    $r->minimum_amount = 0.00; 
    $r->minimum_amount_tax = 0; 
    $r->minimum_amount_currency = 1; 
    $r->minimum_amount_shipping = 1; 
    $r->country_restriction = 0; 
    $r->carrier_restriction = 0; 
    $r->group_restriction = 0; 
    $r->cart_rule_restriction = 0; 
    $r->product_restriction = 1; 
    $r->shop_restriction = 0; 
    $r->free_shipping = 0; 
    $r->reduction_percent = $descuento; 
    $r->reduction_amount = 0.00; 
    $r->reduction_tax = 0; 
    $r->reduction_currency = 1; 
    $r->reduction_product = $cod_prod; 
    $r->reduction_exclude_special = 0; 
    $r->gift_product = 0; 
    $r->gift_product_attribute = 0; 
    $r->highlight = 0; 
    $r->active = 1; 
    $r->date_add = date("YY-mm-dd"); 
    $r->date_upd = date("YY-mm-dd"); 


    //this creates the coupon 
    $r->add();  

나는 할인 부분에 관리자에서 확인할 수 있습니다, 다음과 같이 모든 쇼핑 카트 그리드의 시점에서 아약스를 통해 제품과 고객이 코드는 규칙이 생성되지만 주문이 끝나면 관리자에게 표시되며 주문에는 할인이 지정되지 않으며 아무 곳에서나 사용자가 규칙의 백분율을 감할 수있는 장바구니 규칙을 가지고 있어야합니다. 나는 카트 규칙을 연결하지 않은

답변

1

사전에

덕분에, 나는이 선을했다 완벽하게

$values = array(
     'tax_incl' => $r->getContextualValue(true), 
     'tax_excl' => $r->getContextualValue(false) 
    ); 

    $context->cart->addCartRule($r->id, $r->name[Configuration::get('PS_LANG_DEFAULT')], $values); 
근무
관련 문제