trace Posted July 20, 2017 Share Posted July 20, 2017 (edited) If there is a virtual product in the cart, then "address1" is not required, else it is required. How to do that? Please, help! Edited July 20, 2017 by trace (see edit history) Link to comment Share on other sites More sharing options...
trace Posted July 22, 2017 Author Share Posted July 22, 2017 Anybody can help me? Link to comment Share on other sites More sharing options...
bellini13 Posted July 22, 2017 Share Posted July 22, 2017 i'm not sure what you mean by "address1", however Prestashop is designed to require a billing address. A shipping address is not required if the cart only contains virtual products. 1 Link to comment Share on other sites More sharing options...
trace Posted July 22, 2017 Author Share Posted July 22, 2017 i'm not sure what you mean by "address1", however Prestashop is designed to require a billing address. A shipping address is not required if the cart only contains virtual products. Thank you for your reply. I need an "address1" is required for everywhere. But if cart with only virtual products, this field need to be not required. Link to comment Share on other sites More sharing options...
bellini13 Posted July 23, 2017 Share Posted July 23, 2017 My original reply does not change And what does "address1" mean? Is that invoice or delivery address? 1 Link to comment Share on other sites More sharing options...
trace Posted July 24, 2017 Author Share Posted July 24, 2017 (edited) Delivery address. I'm more interested in how to get data from the shopping cart. If virtual cart (only virtual products in cart) do something, else - do something. How to do something like this: if (in_array('address1', $arr) && $is_virtual) { $this->def['fields']['address1']['required'] = 0; } else if (in_array('address1', $arr) && !$is_virtual) { $this->def['fields']['address1']['required'] = 1; $this->fieldsRequired[] = 'address1'; } else { $this->def['fields']['address1']['required'] = 0; } Edited July 25, 2017 by trace (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted July 24, 2017 Share Posted July 24, 2017 The cart object has a function isVirtualCart that will tell you if it is virtual or not. $context = Context::getContext(); $cart = $context->cart; $is_virtual = $cart->isVirtualCart(); 1 Link to comment Share on other sites More sharing options...
trace Posted July 25, 2017 Author Share Posted July 25, 2017 bellini13, Thank you! It's working. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now