저는 ZenCart 1.5.1 및 "TaxCloud"라고하는 사용자 지정 모드로 작업하고 있습니다.ZenCart에서 진행중인 주문의 총 할인을 검색합니다.
모듈 ot_coupon.php
에 의해 계산중인 활성, 공정 오더의 할인 합계를 검색하는 방법이 있는지 알고 싶습니다. (아직 완료되지 않았지만 완료되는 순서대로)
값이 $od_amount['total']
이라는 변수에 저장되어 있다는 것을 알고 있습니다. 또한 checkout_payment
및 checkout_confirmation
페이지에 표시됩니다.
하지만 그 값을 여기에
참조 할 필요는 ZenCart 1.5.1의 ot_coupon.php
에서 관련 코드입니다. PHP 클래스의 일부입니다. 정확히 같은 일을하려고하는 것은 아니지만
function calculate_deductions($order_total) {
global $db, $order, $messageStack, $currencies;
$currencyDecimalPlaces = $currencies->get_decimal_places($_SESSION['currency']);
$od_amount = array('tax'=>0, 'total'=>0);
if ($_SESSION['cc_id'])
{
$coupon = $db->Execute("select * from " . TABLE_COUPONS . " where coupon_id = '" . (int)$_SESSION['cc_id'] . "'");
$this->coupon_code = $coupon->fields['coupon_code'];
$orderTotalDetails = $this->get_order_total($_SESSION['cc_id']);
if ($coupon->RecordCount() > 0 && $orderTotalDetails['orderTotal'] != 0)
{
if (strval($orderTotalDetails['orderTotal']) >= $coupon->fields['coupon_minimum_order'])
{
switch($coupon->fields['coupon_type'])
{
case 'S':
$od_amount['total'] = $orderTotalDetails['shipping'];
$od_amount['type'] = 'S';
$od_amount['tax'] = ($this->calculate_tax == 'Standard') ? $orderTotalDetails['shippingTax'] : 0;
if (isset($_SESSION['shipping_tax_description']) && $_SESSION['shipping_tax_description'] != '') {
$od_amount['tax_groups'][$_SESSION['shipping_tax_description']] = $od_amount['tax'];
}
return $od_amount;
break;
case 'P':
$od_amount['total'] = zen_round($orderTotalDetails['orderTotal']*($coupon->fields['coupon_amount']/100), $currencyDecimalPlaces);
$od_amount['type'] = $coupon->fields['coupon_type'];
$ratio = $od_amount['total']/$orderTotalDetails['orderTotal'];
break;
case 'F':
$od_amount['total'] = zen_round($coupon->fields['coupon_amount'] * ($orderTotalDetails['orderTotal']>0), $currencyDecimalPlaces);
$od_amount['type'] = $coupon->fields['coupon_type']; // amount off 'F' or amount off and free shipping 'O'
$ratio = $od_amount['total']/$orderTotalDetails['orderTotal'];
break;
}
switch ($this->calculate_tax)
{
case 'None':
break;
case 'Standard':
if ($od_amount['total'] >= $orderTotalDetails['orderTotal']) $ratio = 1;
foreach ($orderTotalDetails['orderTaxGroups'] as $key=>$value)
{
$od_amount['tax_groups'][$key] = zen_round($orderTotalDetails['orderTaxGroups'][$key] * $ratio, $currencyDecimalPlaces);
$od_amount['tax'] += $od_amount['tax_groups'][$key];
if ($od_amount['tax_groups'][$key] == 0) unset($od_amount['tax_groups'][$key]);
}
if (DISPLAY_PRICE_WITH_TAX == 'true' && $coupon->fields['coupon_type'] == 'F') $od_amount['total'] = $od_amount['total'] + $od_amount['tax'];
break;
case 'Credit Note':
$tax_rate = zen_get_tax_rate($this->tax_class);
$od_amount['tax'] = zen_calculate_tax($od_amount['total'], $tax_rate);
$tax_description = zen_get_tax_description($this->tax_class);
$od_amount['tax_groups'][$tax_description] = $od_amount['tax'];
}
}
}
}
return $od_amount;
}