mauricioarango Posted March 27, 2014 Share Posted March 27, 2014 (edited) Hi, I'm working on a very customized prestashop site. Version 1.4.10. The client is selling both physical and virtual products. I'm having 2 main issues: 1. When it is a 'mixed' cart (both physical and virtual) in the carrier selection step a special message has to appear. I can detect when the cart is made up by only virtual products ( $isVirtualCart ) BUT haven't figured out how to detect the presence of both physical and virtual. 2. If it is only a virtual cart the customer receives an email with a donwload link after purchasing and payment being accepted -expected behavior. But if it is a mixed cart the customer is not receiving any download link emails... I checked and the orders show a 'Payment Accepted' status. Any help on these topics would be really appreciated. Thank you so much! Edited March 27, 2014 by mauricioarango (see edit history) Link to comment Share on other sites More sharing options...
mauricioarango Posted March 28, 2014 Author Share Posted March 28, 2014 ...anyone? Link to comment Share on other sites More sharing options...
El Patron Posted March 28, 2014 Share Posted March 28, 2014 ...anyone? have you tried a test with native installation without modifications to see if mixed and real products work? I'd start there to see if PrestaShop without change supports this...if it does then we can say that there is something in the customization that is wrong. Link to comment Share on other sites More sharing options...
mauricioarango Posted April 15, 2014 Author Share Posted April 15, 2014 I'm posting this here in case anyone finds it useful. It applies to PS 1.4.x ... but I imagine it can be easily adapted to newer versions.In sum, PS considers a cart virtual only when ALL of its products are virtual (makes sense). If for whatever business logic you need to change this behavior and make the cart virtual when there's at least ONE virtual product then you need to change this:classes > Cart.phpLine 1497 to 1528:/** * Check if cart contains only virtual products * @return boolean true if is a virtual cart or false * */ public function isVirtualCart() { if (!isset(self::$_isVirtualCart[$this->id])) { $products = $this->getProducts(); if (!count($products)) return false; $list = ''; foreach ($products as $product) $list .= (int)$product['id_product'].','; $list = rtrim($list, ','); $n = (int)Db::getInstance()->getValue(' SELECT COUNT(`id_product_download`) n FROM `'._DB_PREFIX_.'product_download` WHERE `id_product` IN ('.pSQL($list).') AND `active` = 1'); /* CHANGE PRESTASHOP defines a cart as virtual when all the products on it are virtual items. We need the cart to be taken as virtual when at least only 1 product is virtual self::$_isVirtualCart[$this->id] = ($n == count($products)); */ self::$_isVirtualCart[$this->id] = ($n >= 1); } return self::$_isVirtualCart[$this->id]; } 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