Jump to content

Jurist

Members
  • Posts

    151
  • Joined

  • Last visited

Everything posted by Jurist

  1. Hi Rod, That's what default PS alias functionality does. If someone types "blouse" you see search results matching "blouse" keyword. Without any alias, if someone types "blous" there are no results since it's not matching anything. However if you add alias "blous" -> "blouse" in back office, when someone types "blous" he sees search results as if he typed "blouse". I tested it and it was working, however it was not quite the functionality I wanted. Maybe I should add wildcard option with redirection to my module, for example you could add search query: "%blous%" that would match any query with "blous" keyword inside, that would either show search results for another keyword "blouse" for example or redirect to specified site. If someone was interested I may add that. Kind regards
  2. Dear Rod, I managed to create a module that redirects specific search phrase into specific site. For example "red t-shirt" will redirect to "yoursite.com/red-t-shirts" "x size dress" could redirect to "yoursite.com/small-size-dresses" you would need to add those redirections manually. Let me know in private message if you're interested. Kind regards
  3. Hello, To make every day tasks easier for the stores I am working for, I've received a request to allow cancelation invoice to be created. It needs to be simple document, similar to an invoice, only with values negated. I know that invoice is generated with the link in back office: submitAction=generateInvoicePDF&id_order_invoice=11111 I am going to create a similar button, with Generate cancelation invoice name, link probably will need to be something line that: submitAction=generateCancelationInvoicePDF&id_order_invoice=11111 I know the method needs to be created, in AdminPdfController.php file. The problem is, where the invoice data is loaded from? Function getInvoicesCollection doesn't show anything interesting, it's only related to getSibling method of OrderInvoice.php Where do I negate the values on the invoice? In the other places some values would need to be zeroed. Thanks
  4. We moved to a different hosting and made major upgrade to Prestashop 1.7. There was something I did which fixed the problem even in Prestashop 1.6 however I don't remember now what it was unfortunately :(
  5. Thanks guys for the reply. I couldn't get the override to work so for now I just edited core class file. In some time I will probably restore it and will try to create override again, then post the result here. Thanks
  6. Thanks for you reply. Obviously I cleared cache. I read that overriding some classes is not allwed (like Customer.php or Product.php) for example. That's why I asked my question, since I would like to know, how to implement changes, like combination price impact not being discounted, so it's not removed when one click update is done.
  7. I used to alter the default PS classes behaviour by creating a class file called for example Customer.php and putting it into overrides folder in PS 1.6 Now I have a task to remove discount from product attribute, which is calculated in Product.php file. I made same override I've been doing in the past, however no changes are reflected whatsoever. Even if I break the code on purpose nothing happens. Looks like the class is not loaded at all. How do I deal with that? There's no option in PS anywhere to switch discount from combinations on and off. Thank you
  8. Hi Crezzur, I've literally did that change yesterday: // $swift->registerPlugin(new \Swift_Plugins_DecoratorPlugin(array($toPlugin => $templateVars))); $swift->registerPlugin(new \Swift_Plugins_DecoratorPlugin(array(self::toPunycode($toPlugin) => $templateVars))); I found it on github, couldn't find on the forum for some reason. Thanks
  9. Hello, We have a store where customer enters company and vat details during checkout and account opening (b2b option enabled). However immediately after that company field is empty, which means he needs to insert it again. Is there any way to automatically add company name to the new address?
  10. A customer just complained he received a message looking like that: I checked his order, everything looks fine. I made another test order and everything looks fine. Why this happened and why PS 1.7 is so riddle with bugs in every corner? Thanks
  11. Okay I found it: private function create(Customer $customer, $clearTextPassword) { if (!$clearTextPassword) { $clearTextPassword = Tools::passwdGen(8); } if (!$clearTextPassword) { if (!$this->guest_allowed) { $this->errors['password'][] = $this->translator->trans( 'Password is required', [], 'Shop.Notifications.Error' ); return false; } /** * Warning: this is only safe provided * that guests cannot log in even with the generated * password. That's the case at least at the time of writing. */ $clearTextPassword = $this->crypto->hash( microtime(), _COOKIE_KEY_ ); $customer->is_guest = true; } However since it's private method, I am unable to create override for it. What's the way it should be done? Changing content of the core class is no good, since after update the changes will be lost. Any support from the forum would be appreciated...
  12. Dear Knowband, Do you know by any chance where there's a condition if password field was valid? Probably in some class or controller file, but you have an idea where exactly? I would like to add a code generating a password for customer when he doesn't insert one (so the customers think they are registering as guest while technically they are normal customers). This is vital for any loyalty policy. Would be very, very grateful for your reply.
  13. Where PS1.7 checks whether password was provided during checkout or not (decide whether guest or customer)? Help please...
  14. Could anybody give me an idea where do I should at least begin searching for that line? If password given during create account empty, then generate it for customer? I tried javascript approach, but it doesn't work as intended.
  15. As in title, where should I add the code checking if password given was empty, and if yes to generate some random pass? To avoid guest customers, that are harmful (people can't log in again). In PS 1.6, it was AuthController.php protected function processSubmitAccount() { Hook::exec('actionBeforeSubmitAccount'); $this->create_account = true; if (Tools::isSubmit('submitAccount')) { $this->context->smarty->assign('email_create', 1); } // New Guest customer if (!Tools::getValue('is_new_customer', 1) && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) { $this->errors[] = Tools::displayError('You cannot create a guest account.'); } if (!Tools::getValue('is_new_customer', 1)) { $_POST['passwd'] = md5(time()._COOKIE_KEY_); } where is equivalent in prestashop 1.7? Thanks
  16. Man, I really appreciate your time and help. However I have no possibility of adding extra button / changes to .tpl files. Please have a look here: https://dev.wetroomsdesign.co.uk/wet-room-kit-800-x-800-line-ponente Add to cart button is meant to add another products to the shopping cart if appropriate select options are chosen. I am trying to do that with: function addProduct(id_product, quantity, totalQty, delay) { const token = prestashop.static_token; const url = prestashop.urls.pages.cart; const query = 'controller=cart&add=1&action=add&ajax=true&token=' + token + '&id_product=' + id_product + '&id_customization=0&qty=' + totalQty; var controllerUrl = url.concat(query); var functionName = "addToCart"; $.ajax({ cache: false, data: query, beforeSend: function () { setTimeout(delay); }, success: function(resp) { // console.log(resp); prestashop.emit('updateCart', { reason: {}, resp: resp }); }, error: function(resp) { // console.log(resp); prestashop.emit('handleError', {eventType: 'addProductToCart', resp: resp}); } }); } and it works but only if someone has cart created before. If user adds to cart for the first time, the original product is overwritten. I need to fire it from javascript. Any ideas?
  17. hi ndiaga, Could you please show me sample how to call it? I tried reading documentation but couldn't find such info anywhere. I've spent few days on that and cannot solve the problem I have...
  18. Where specifically in the file you see it called?
  19. I checked that file contents but I think its called elsewhere, it's just template file that generates html content, which may then be used to fire JS event that adds product to shopping cart. I need to add another product that is not shown on this product page (as accessory), that's why I use JS: if checkbox is selected, then add product id 786 to shopping cart as well. It works but the problem is, new cart with product id 786 overwrites old cart with original product which means only product id 786 is now in cart. I need to make sure cart is not empty and add it only after original product is added (which creates appropriate cart as well). I am thinking about setting interval and checking cart quantity...
  20. Hi @ndiaga, Do you mean _dev/cart.js? File is hard to read and understand, which part is responsible for adding product to shopping cart? Basically the only problem I have with my function is that it add the product I want to shopping cart, but sometimes adds a new shopping cart which leaves 'original' product behind. Is there a way to make sure that the event is fired only after previous add to cart action is done? Maybe I should change query somehow?
  21. Hi @ndiaga, I have created it other way, without using custom controller and using cartController instead. The problem I have is that sometimes on add to cart button click, the store adds products from my function first, which are then overwritten by the product that the add to cart button is clicked on. There's code: function addProduct(id_product, quantity, totalQty) { const token = prestashop.static_token; const url = prestashop.urls.pages.cart; const query = 'controller=cart&add=1&action=update&ajax=true&token=' + token + '&id_product=' + id_product + '&id_customization=0&qty=' + totalQty; var controllerUrl = url.concat(query); var functionName = "addToCart"; // var delay = 10; $.ajax({ // url: controllerUrl, headers: { "cache-control": "no-cache" }, cache: false, async: false, data: query, beforeSend: function () { // setTimeout(delay); }, success: function(resp) { // console.log(resp); prestashop.emit('updateCart', { reason: {}, resp: resp }); }, error: function(resp) { // console.log(resp); prestashop.emit('handleError', {eventType: 'addProductToCart', resp: resp}); } }); } Do you have an idea how to fire the event after the original product was added to the shopping cart? So the products added by the function are added after, to an existing cart. I would be very grateful for your help. Kind regards
  22. Hi ndiaga, Thank you very much for your answer, much appreciated. You quoted Cart.php core, which I have not edited in any way. $cart->updateQty((int)$quantity, (int)$id_product, $attribute, false); called in my class causes the problem. Not sure why but for some reason, Cart.php, called from my module's class 'doesn't see' $id_cart.
  23. Hello, I am trying to create a small module that adds another products to the shopping cart through ajax call to module's controller. It works, however I get fatal error: Fatal error: Uncaught PrestaShopException: Fatal error in /home/xxxxyyyy/dev.xxxxyyyy.co.uk/classes/Tools.php:1175 Stack trace: #0 /home/xxxxyyyy/dev.xxxxyyyy.co.uk/classes/Product.php(3170): ToolsCore::displayError() #1 /home/xxxxyyyy/dev.xxxxyyyy.co.uk/classes/Product.php(4780): ProductCore::getPriceStatic(786, false, 0, 6, NULL, false, true, 2) #2 /home/xxxxyyyy/dev.xxxxyyyy.co.uk/classes/Cart.php(790): ProductCore::getProductProperties(1, Array) #3 /home/xxxxyyyy/dev.xxxxyyyy.co.uk/classes/Cart.php(1467): CartCore->getProducts(true) #4 /home/xxxxyyyy/dev.xxxxyyyy.co.uk/modules/productAsCombination/productAsCombination.php(242): CartCore->updateQty(2, 786, 0, false) #5 /home/xxxxyyyy/dev.xxxxyyyy.co.uk/modules/productAsCombination/controllers/front/ProductAsCombinationController.php(9): ProductAsCombination->addProductToCart(786, 2, NULL) #6 /home/xxxxyyyy/dev.xxxxyyyy.co.uk/modules/productAsCombination/controllers/front/Pro in /home/xxxxyyyy/dev.xxxxyyyy.co.uk/classes/Tools.php on line 1175 I found that if I comment out: if (!is_object($cur_cart) || (Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart)) { /* * When a user (e.g., guest, customer, Google...) is on PrestaShop, he has already its cart as the global (see /init.php) * When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID * When called from the back office, cart ID can be inexistant */ if (!$id_cart && !isset($context->employee)) { //die(Tools::displayError()); } $cur_cart = new Cart($id_cart); // Store cart in context to avoid multiple instantiations in BO if (!Validate::isLoadedObject($context->cart)) { $context->cart = $cur_cart; } } Line die(Tools::displayError()); the error is no more. My controller: public function addToCart($id_product, $quantity, $attribute) { $productsAsCombination = new productAsCombination(); if(!$productsAsCombination->addProductToCart($id_product, $quantity, $attribute)) return false; $price = Product::getPriceStatic($id_product); // $price = 69; return $price; } } if(isset($_GET['function'])) { if($_GET['function'] == 'addToCart' && $_GET['id_product'] && $_GET['quantity']) { $ProductAsCombinationController = new ProductAsCombinationController(); $id_product = (int)$_GET['id_product']; $quantity = (int)$_GET['quantity']; $attribute = null; $data = $ProductAsCombinationController->addToCart($id_product, $quantity, $attribute); echo json_encode($data); } } and module's class: public function addProductToCart($id_product, $quantity, $attribute = null) { $context=Context::getContext(); if ($this->context->cookie->id_cart) { $cart = new Cart($this->context->cookie->id_cart); } // create new cart if needed if (!isset($cart) OR !$cart->id) { $cart = new Cart($this->context->cookie->id_cart); $cart->id_customer = (int)($this->context->cookie->id_customer); $cart->id_address_delivery = (int) (Address::getFirstCustomerAddressId($cart->id_customer)); $cart->id_address_invoice = $cart->id_address_delivery; $cart->id_lang = (int)($this->context->cookie->id_lang); $cart->id_currency = (int)($this->context->cookie->id_currency); $cart->id_carrier = 1; $cart->recyclable = 0; $cart->gift = 0; $cart->add(); $this->context->cookie->id_cart = (int)($cart->id); } $cart->update(); $cart->updateQty((int)$quantity, (int)$id_product, $attribute, false); $cart->update(); } Anybody could tip where there's a problem? Apparently $id_cart is not defined when Product::getPriceStatic is called by CartCore. My module is working, however Internal server error from ajax call gives me anxiety. Any help, will be much appreciated.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More