Prestashop 1.7 模块:需要获取 "Country" 和 "State" 名称,"Products" 和 "Order message"
Prestashop 1.7 module : Need to get "Country" and "State" names, "Products" and "Order message"
我正在开发一个模块,当订单状态被管理员更改为 “已发货” 时,它会获得 订单详细信息,post 他们使用 api 到第三方应用程序。我正在使用 Prestashop V 1.7.7.0.
我还需要获取 “国家” 和 “州”名称、“产品” 和 “订购消息”。请问我该怎么做?
另外,prestashop 中无法安装该模块。我的代码正确吗?
需要帮助。谢谢
public function hookActionOrderStatusPostUpdate($params)
{
if($params['newOrderStatus']->id == 13)
{
$order = new Order((int)$params['id_order']);
$address = new Address((int)$order->id_address_delivery);
$customer = new Customer((int)($address->id_customer));
$country = new Country((int)($address->id_country));
$state = new Country((int)($address->id_state));
$tel_cl = $address->phone;
$name_lastname_cl = $address->lastname . ' ' . $address->firstname;
$country_cl = **Not yet**;
$state_cl = **Not yet**;
$adress_cl = $address->address1 . ' ' . $address->address2;
$tel_2_cl = $address->phone_mobile
$products = **Not yet**;
$quantity = "1"
$cod = $order->total_paid
$note = **Not yet(order message)**;
$Url_str = 'http://example.com/api/set_parcel_post.php?id=123&tel_cl='.$tel_cl.'&name_lastname_cl='.$name_lastname_cl.'&country_cl='.$country_cl.'&state_cl='.$state_cl.'&address_cl='.$address_cl.'&tel_2_cl='.$tel_2_cl.'&products='.$products.'&cod='.$cod.'&Quantity='.$Quantity.'¬e='.$note;
$json = file_get_contents($Url_str);
$result = json_decode($json);
}
}
您不能使用 id_state 实例化国家/地区对象,因此:
$state = new Country((int)($address->id_state));
错了,应该是
$state = new State((int) $address->id_state);
所以你可以得到像$state->name
这样的州名,
要获取产品订单,您可以使用 $order->getProducts();
,这将 return 一个包含订单产品及其信息(名称、价格等)的数组
我正在开发一个模块,当订单状态被管理员更改为 “已发货” 时,它会获得 订单详细信息,post 他们使用 api 到第三方应用程序。我正在使用 Prestashop V 1.7.7.0.
我还需要获取 “国家” 和 “州”名称、“产品” 和 “订购消息”。请问我该怎么做?
另外,prestashop 中无法安装该模块。我的代码正确吗?
需要帮助。谢谢
public function hookActionOrderStatusPostUpdate($params)
{
if($params['newOrderStatus']->id == 13)
{
$order = new Order((int)$params['id_order']);
$address = new Address((int)$order->id_address_delivery);
$customer = new Customer((int)($address->id_customer));
$country = new Country((int)($address->id_country));
$state = new Country((int)($address->id_state));
$tel_cl = $address->phone;
$name_lastname_cl = $address->lastname . ' ' . $address->firstname;
$country_cl = **Not yet**;
$state_cl = **Not yet**;
$adress_cl = $address->address1 . ' ' . $address->address2;
$tel_2_cl = $address->phone_mobile
$products = **Not yet**;
$quantity = "1"
$cod = $order->total_paid
$note = **Not yet(order message)**;
$Url_str = 'http://example.com/api/set_parcel_post.php?id=123&tel_cl='.$tel_cl.'&name_lastname_cl='.$name_lastname_cl.'&country_cl='.$country_cl.'&state_cl='.$state_cl.'&address_cl='.$address_cl.'&tel_2_cl='.$tel_2_cl.'&products='.$products.'&cod='.$cod.'&Quantity='.$Quantity.'¬e='.$note;
$json = file_get_contents($Url_str);
$result = json_decode($json);
}
}
您不能使用 id_state 实例化国家/地区对象,因此:
$state = new Country((int)($address->id_state));
错了,应该是
$state = new State((int) $address->id_state);
所以你可以得到像$state->name
这样的州名,
要获取产品订单,您可以使用 $order->getProducts();
,这将 return 一个包含订单产品及其信息(名称、价格等)的数组