我從送貨地址,我想所有的數據與此產品:的Prestashop得到一個訂單
public function getOrderShippingCost($params, $shipping_cost)
{
global $smarty;
$url = Tools::getHttpHost(true).__PS_BASE_URI__;
$address = new Address($this->context->cart->id_address_delivery);
$state = new State ($address->id_state);
$country = new Country ($address->id_country);
echo $address->postcode;
echo $address->country;
echo $address->address1;
echo $address->address2;
echo $state->name;
echo $country->iso_code;
,結果是好的,但現在我怎樣才能得到訂單的產品?
我試試這個代碼:
$products = $params['cart']->getProducts(true);
,但這樣做的結果是Fatal error: Cannot use object of type Cart as array in
如果我嘗試這樣的事:
$order = new Order($this->context->order->id_order);
的結果有兩個錯誤:
Notice: Undefined property: Context::$order in /var/www/prestashop/modules/mycarrier/mycarrier.php on line 325
Notice: Trying to get property of non-object in /var/www/prestashop/modules/mycarrier/mycarrier.php on line 325
如何獲得產品?