Prestashop:如何在 Address.php 中使用购物车中的虚拟产品?
Prestashop: How to get virtual product in the cart for use in Address.php?
在 Prestashop CMS 中,address1 只有在购物车中有虚拟产品时才需要。
如何实现?有人对此有解决方案吗?
$context = Context::getContext();
$cart = $context->cart;
$is_virtual = $cart->isVirtualCart();
完美运行。示例:
if (in_array('address1', $arr) && $is_virtual) {
$this->def['fields']['address1']['required'] = 0;
} else if (in_array('address1', $arr)) {
$this->def['fields']['address1']['required'] = 1;
$this->fieldsRequired[] = 'address1';
} else {
$this->def['fields']['address1']['required'] = 0;
}
在 Prestashop CMS 中,address1 只有在购物车中有虚拟产品时才需要。
如何实现?有人对此有解决方案吗?
$context = Context::getContext();
$cart = $context->cart;
$is_virtual = $cart->isVirtualCart();
完美运行。示例:
if (in_array('address1', $arr) && $is_virtual) {
$this->def['fields']['address1']['required'] = 0;
} else if (in_array('address1', $arr)) {
$this->def['fields']['address1']['required'] = 1;
$this->fieldsRequired[] = 'address1';
} else {
$this->def['fields']['address1']['required'] = 0;
}