1

prestashop API(Webサービス)を利用して注文しようと思っています。私は終わりに近づいていますが、以下に関するいくつかの情報が欠けています:

  • 税金費用
  • 輸送費

この種の情報を取得するためのルートやプロセスを誰かが知っていれば、非常に役に立ちます。

4

2 に答える 2

0

これは少し古いことは知っていますが、次の方法でWebサービスを介してこれらの情報を取得できました。

編集された 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);

}

コードの一部を改善できるかもしれませんが、これはある程度の方法です。

最高です、エダー。

于 2015-07-13T21:24:16.207 に答える
0

よくわかりませんが、送料については機能にあると思います:

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で使用されていますが、どのようなモジュールを作成していますか?

于 2013-06-26T05:58:21.990 に答える