MateuszSkrypty Posted April 24, 2017 Share Posted April 24, 2017 Witam, w jaki sposób jestem w stanie ograniczyć ilość zamawianych produktów jednego rodzaju? Klient jest w stanie zamówić wiele różnych produktów, ale zawsze w ilości 1 sztuki. Zdisplayowałem ilości w całym sklepie, ale gdy klient doda do koszyka produkt po czym kontynuuje zakupy i ponownie doda ten sam produkt ilość liczona jest jako 2. W jaki sposób jestem w stanie to ograniczyć?Pozdrawiam Mateusz Link to comment Share on other sites More sharing options...
vekia Posted April 24, 2017 Share Posted April 24, 2017 Standardowo nie ma takiej funkcji, pozostaje gotowy moduł do definiowania takich ograniczeń, albo dedykowane rozwiązanie pod kątem potrzeb. Kluczowe jest tutaj "produktów jednego rodzaju". Chodzi o unikalne produkty, czy "produkt jednego rodzaju" to np. produkty z wybranych kategorii np. "spodnie" ? Link to comment Share on other sites More sharing options...
MateuszSkrypty Posted April 24, 2017 Author Share Posted April 24, 2017 Chodziło mi o to by każdy z produktów w sklepie był możliwy do zamówienia w ilości sztuk 1. Klient może zamówić 100 różnych produktów, przy czym po 1 sztuce każdy.Czy istnieją darmowe rozwiązania tego problemu? Link to comment Share on other sites More sharing options...
vekia Posted April 24, 2017 Share Posted April 24, 2017 Ok, wszystko jasne, podaj jeszcze proszę numer wersji prestashop (konkretny numer) napiszę Ci odpowiedni kod do wstawienia do kontrolera koszyka. W tym wariancie modyfikacji czyszczenie odbywać się będzie z poziomu koszyka. Więc wszystko powinno zadziałać zgodnie z opisaną przez Ciebie problematyką.nie znam żadnego darmowego rozwiązania. Link to comment Share on other sites More sharing options...
MateuszSkrypty Posted April 24, 2017 Author Share Posted April 24, 2017 1.6.1.4 Link to comment Share on other sites More sharing options...
vekia Posted April 24, 2017 Share Posted April 24, 2017 1.6.1.4 w pliku: controllers/front/OrderController.php tuż za kodem: // Check minimal amount $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $orderTotal = $this->context->cart->getOrderTotal(); $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) { $_GET['step'] = $this->step = 0; $this->errors[] = sprintf( Tools::displayError('A minimum purchase total of %1s (tax excl.) is required to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ); } dodajemy: $changed = 0; foreach (Context::getContext()->cart->getProducts() as $product) { if ($product['cart_quantity'] > 1) { var_dump(Context::getContext()->cart->updateQty(1,$product['id_product'],$product['id_product_attribute'],false,'down',0,null,null)); $changed = 1; } } if ($changed == 1){ $_GET['step'] = $this->step = 0; $this->errors[] = Tools::displayError('We accept only 1 quantity of product. So we changed quantity of products to 1.'); } efekt, gdy przechodząc do zamawiania w koszyku będą więcej niż 2 sztuki danego produktu: w przypadku potrzeby bardziej zaawansowanych warunków polecam swoje moduły jak cart conditions pro / minimal quantity dostępne tutaj Link to comment Share on other sites More sharing options...
MateuszSkrypty Posted April 25, 2017 Author Share Posted April 25, 2017 Dziękuje serdecznie za pomoc!Dokładnie o to mi chodziło Pozdrawiam Mateusz Link to comment Share on other sites More sharing options...
Jullita Posted March 20, 2020 Share Posted March 20, 2020 On 4/24/2017 at 5:32 PM, vekia said: $changed = 0; foreach (Context::getContext()->cart->getProducts() as $product) { if ($product['cart_quantity'] > 1) { var_dump(Context::getContext()->cart->updateQty(1,$product['id_product'],$product['id_product_attribute'],false,'down',0,null,null)); $changed = 1; } } if ($changed == 1){ $_GET['step'] = $this->step = 0; $this->errors[] = Tools::displayError('We accept only 1 quantity of product. So we changed quantity of products to 1.'); } A co trzeba zmienić w tym kodzie, aby zadziałał w 1.5.4.1? 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