我希望使用 prestashop API(网络服务)下订单。我即将结束,但它仍然错过了一些关于:
- 税收成本
- 运输费
如果有人知道获取此类信息的路线或流程,那将非常有帮助。
我希望使用 prestashop API(网络服务)下订单。我即将结束,但它仍然错过了一些关于:
如果有人知道获取此类信息的路线或流程,那将非常有帮助。
我不确定,但关于运费,我认为它在功能中:
public function getOrderShippingCost($params, $shipping_cost) {
// This example returns shipping cost with overcost set in the back-office, but you can call a webservice or calculate what you want before returning the final value to the Cart
if ($this->id_carrier == (int)(Configuration::get('MYCARRIER1_CARRIER_ID')) && Configuration::get('MYCARRIER1_OVERCOST') > 1)
return (float)(Configuration::get('MYCARRIER1_OVERCOST'));
if ($this->id_carrier == (int)(Configuration::get('MYCARRIER2_CARRIER_ID')) && Configuration::get('MYCARRIER2_OVERCOST') > 1)
return (float)(Configuration::get('MYCARRIER2_OVERCOST'));
// If the carrier is not known, you can return false, the carrier won't appear in the order process
return false;
}
但是它在 CarrierModule 中使用,您正在创建什么样的模块?
我知道这有点老了,但我设法通过这种方式通过网络服务获取这些信息:
编辑 Cart.php 核心类(有一种更优雅的方式,但这也有效)。
// added 2 attributes in class
public $my_shipping_cost;
public $my_order_total;
// added some more data to $webserviceParameters
protected $webserviceParameters = array(
'fields' => array(
'id_address_delivery' => array('xlink_resource' => 'addresses'),
'id_address_invoice' => array('xlink_resource' => 'addresses'),
'id_currency' => array('xlink_resource' => 'currencies'),
'id_customer' => array('xlink_resource' => 'customers'),
'id_guest' => array('xlink_resource' => 'guests'),
'id_lang' => array('xlink_resource' => 'languages'),
'my_shipping_cost' => array(
'getter' => 'getMyShippingCost',
'setter' => 'getMyShippingCost'
),
'my_order_total' => array(
'getter' => 'getMyOrderTotal',
'setter' => 'getMyOrderTotal',
),
), ...
// added some methods to process the values
public function getMyShippingCost(){
if (!isset($this->my_shipping_cost))
$this->setMyCustomFieldsValues();
return $this->my_shipping_cost;
}
public function getMyOrderTotal(){
if (!isset($this->my_order_total))
$this->setMyCustomFieldsValues();
return $this->my_order_total;
}
public function setMyCustomFieldsValues(){
if (!isset($this->id))
return;
$currency = 1;
$taxCalculationMethod = Group::getPriceDisplayMethod((int)Group::getCurrent()->id);
$useTax = !($taxCalculationMethod == PS_TAX_EXC);
$base_shipping = $this->getOrderTotal($useTax, Cart::ONLY_SHIPPING, null, $this->id_carrier, false);
$this->my_shipping_cost = $base_shipping;
$this->my_order_total = $this->getOrderTotal($useTax, Cart::BOTH, null, $this->id_carrier, false);
}
也许你可以改进一些代码,但这是一段路要走。
最好的,埃德。