我从递送地址中获得了我想要的所有数据:
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怎样才能得到产品呢?
发布于 2016-03-03 16:54:59
您已经在使用:
new Address($this->context->cart->id_address_delivery);所以我认为你可以使用:
$products = $this->context->cart->getProducts(true);发布于 2017-04-25 15:38:16
您需要加载order detail对象来获取prestashop中特定订单id的产品。
$ProductDetailObject = new OrderDetail;
$product_detail = $ProductDetailObject->getList($order_id);https://stackoverflow.com/questions/35756909
复制相似问题