2012-02-16 3 views
1

opencart 프로젝트에서 업데이트를하고 있습니다. 우리는 환불을 적용 할 쿠폰을 만듭니다. 결제 페이지에 포함되어 있습니다. 우리는 쿠폰 코드, 할인, 특급 날짜 등 관리자 측면에서이 쿠폰 세부 정보를 추가합니다.하지만 사용자 측에서 아무런 변화가 없습니다. 쿠폰 코드를 입력하는 동안 아무 일도 일어나지 않습니다. 가격 하락도없고 오류 메시지도 표시되지 않았습니다.opencart에서 쿠폰이 작동하지 않습니다.

+0

코드를 디버깅해야합니다. 오류 메시지를 볼 수 있습니까? –

+0

오류 메시지가 표시되지 않았습니다. – Natasha

+0

오류보고 수준, display_errors ini 플래그 및 데이터베이스 오류는 어떻습니까? –

답변

4

정상적인 방법으로 쿠폰을 사용하면 잘못된 것으로 표시됩니다. 그 이유는 날짜가 좀 어색하기 때문입니다. 시작 날짜는 사용하기 하루 전에 설정하고 종료 날짜를 하루 후에 설정해야합니다. OpenCart가 원하는 있기 때문에 날짜 문제가있는 경우

... 그것은 내가 아는 이상한,하지만 그게, 그래서 날짜가 쿠폰 제이의 대답에 확장

0

에 유효한지 확인 작동하는 방법, 그것은이다 쿠폰은 커야한다/

열기 /catalog/model/checkout/coupon.php 날짜 (동일하지 않음)보다

우선 함수 getCoupon한다

이 광고 찾기 :

,691을 363,210
$coupon_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "coupon WHERE code = '" . $this->db->escape($code) . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) AND status = '1'"); 

변경 DATE_START < NOW() < = NOW()

그리고 DATE_END < NOW() 결과 < = NOW()

DATE_END 에 DATE_START 에 :

$coupon_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "coupon WHERE code = '" . $this->db->escape($code) . "' AND ((date_start = '0000-00-00' OR date_start <= NOW()) AND (date_end = '0000-00-00' OR date_end >= NOW())) AND status = '1'"); 
3

쿠폰이 성공적으로 적용되었지만 할인되지 않은 유사한 문제가 발생했습니다.

발견 된 문제는 주문 총 주문 방식으로 인해 '소계'가 '쿠폰'보다 먼저 나와야합니다.

그래서 여기에 모든 코드없이 잘못 게시에게 대답을 기분 내 디버깅을했던 곳이다 : 카탈로그/모델/전체/coupon.php

은 $ 총은 0 그래서 할인 리셋을 얻고 있었다.

// If discount greater than total 
if ($coupon_info['type'] == 'F' && $discount_total > $subtotal) { 
    $discount_total = $subtotal; 
} 

다른 아무도이 일을 디버깅 할 수없는 희망! :

public function getTotal(&$total_data, &$total, &$taxes) { 
    if (isset($this->session->data['coupon'])) { 
     $this->load->language('total/coupon'); 

     $this->load->model('checkout/coupon'); 

     $coupon_info = $this->model_checkout_coupon->getCoupon($this->session->data['coupon']); 

     if ($coupon_info) { 
      $discount_total = 0; 

      if (!$coupon_info['product']) { 
       $sub_total = $this->cart->getSubTotal(); 
      } else { 
       $sub_total = 0; 

       foreach ($this->cart->getProducts() as $product) { 
        if (in_array($product['product_id'], $coupon_info['product'])) { 
         $sub_total += $product['total']; 
        } 
       } 
      } 

      if ($coupon_info['type'] == 'F') { 
       $coupon_info['discount'] = min($coupon_info['discount'], $sub_total); 
      } 

      foreach ($this->cart->getProducts() as $product) { 
       $discount = 0; 

       if (!$coupon_info['product']) { 
        $status = true; 
       } else { 
        if (in_array($product['product_id'], $coupon_info['product'])) { 
         $status = true; 
        } else { 
         $status = false; 
        } 
       } 

       if ($status) { 
        if ($coupon_info['type'] == 'F') { 
         $discount = $coupon_info['discount'] * ($product['total']/$sub_total); 
        } elseif ($coupon_info['type'] == 'P') { 
         $discount = $product['total']/100 * $coupon_info['discount']; 
        } 

        if ($product['tax_class_id']) { 
         $tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']); 

         foreach ($tax_rates as $tax_rate) { 
          if ($tax_rate['type'] == 'P') { 
           $taxes[$tax_rate['tax_rate_id']] -= $tax_rate['amount']; 
          } 
         } 
        } 
       } 

       $discount_total += $discount; 
      } 

      if ($coupon_info['shipping'] && isset($this->session->data['shipping_method'])) { 
       if (!empty($this->session->data['shipping_method']['tax_class_id'])) { 
        $tax_rates = $this->tax->getRates($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']); 

        foreach ($tax_rates as $tax_rate) { 
         if ($tax_rate['type'] == 'P') { 
          $taxes[$tax_rate['tax_rate_id']] -= $tax_rate['amount']; 
         } 
        } 
       } 

       $discount_total += $this->session->data['shipping_method']['cost']; 
      } 

      // If discount greater than total 
      if ($discount_total > $total) { 
       $discount_total = $total; 
      } 

      $total_data[] = array(
       'code'  => 'coupon', 
       'title'  => sprintf($this->language->get('text_coupon'), $this->session->data['coupon']), 
       'value'  => -$discount_total, 
       'sort_order' => $this->config->get('coupon_sort_order') 
      ); 

      $total -= $discount_total; 
     } 
    } 
} 
0

존의 대답에 이어 ... catalog/model/total/coupon.php에서 나는 들어

// If discount greater than total 
if ($discount_total > $total) { 
    $discount_total = $total; 
} 

을 교체