[英]Opencart Shipping Method Required
我根據下面的帖子創建了一個新的運輸模塊
http://forum.opencart.com/viewtopic.php?f=142&t=30226
送貨方式檢查用戶所在的成員組,然后根據購物車價格確定他們是否有資格享受免費送貨服務。 一切都很好,除非您去結帳並選擇免費送貨方式,它會返回錯誤“警告:需要送貨方式!”。
運輸的型號如下,有人可以對此進行說明嗎?
<?php
class ModelShippingFreeusergroup extends Model {
function getQuote($address) {
$this->language->load('shipping/freeusergroup');
$customer_group_id = $this->customer->getCustomerGroupId();
if ($customer_group_id < 1)$customer_group_id = 1;
$cart_total = $this->cart->getTotal();
$strQuery = "SELECT * FROM " . DB_PREFIX . "members_delivery " .
" WHERE price <= '" . $cart_total . "' AND customer_group_id = '" . $customer_group_id . "' " .
" LIMIT 1";
$query = $this->db->query($strQuery);
//$ShipArray = array();
$method_data = array();
if ($query->num_rows > 0)
{
foreach ($query->rows as $result) {
$quote_data['freeusergroup'] = array(
'code' => 'freeusergroup',
'title' => 'Free Delivery',
'cost' => 0.00,
'tax_class_id' => $this->config->get('weight_tax_class_id'),//0,
'text' => $this->currency->format(0.00)
);
$method_data = array(
'code' => 'freeusergroup',
'title' => 'Free Delivery',
'quote' => $quote_data,
'sort_order' => $this->config->get('freeusergroup_sort_order'),
'error' => false
);
}
}
return $method_data;
}
}
?>
我設法解決了這個問題,但我沒有意識到方法數據引用數據需要使用。 在代碼中,檢查控制器上的validate函數使我注意到報價數據中的“代碼”應為“ freeusergroup.freeusergroup”
代碼的第一部分取自method_data,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.