Jump to content

philoupin

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by philoupin

  1. Hi, my custom module is listening to "actionProductUpdate" so additional info can be saved during product update in Admin. However when I "save" a product by hitting the "Save" button on the product information page in Admin, the hook "actionProductUpdate" gets called twice. This is on PS 1.7.6.5. The hook fires once in file classes/Product.php line 644 inside function "update" and in src/Adapter/Product/AdminProductWrapper.php on line 205 inside function "processQuantityUpdate". Is it really intended that the same hook is called twice during one script execution? My module is now called twice during product update and I have to write some ugly code to not insert the same data twice into the DB during the second call. In src/Adapter/Product/AdminProductWrapper.php ist says: // Hook triggered by legacy code below: actionUpdateQuantity('id_product', 'id_product_attribute', 'quantity') StockAvailable::setQuantity((int) $product->id, $forAttributeId, $quantity); Hook::exec('actionProductUpdate', array('id_product' => (int) $product->id, 'product' => $product)); So maybe the hook should rather be called something like "actionProductUpdateQuantity" ? Thanks for any hints on how to elegantly handle the second hook call, in case this is indeed intended behaviour of PS.
  2. PS Version 1.7.5 In order to show a page in the front office with come content of my custom module, I have followed the tutorial here: https://devdocs.prestashop.com/1.7/modules/creation/displaying-content-in-front-office/ to create a ModuleFrontcontroller like so: class mymoduledisplayModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $this->setTemplate('module:mymodule/views/templates/front/display.tpl'); } } the corresponding .tpl file just has a line of "Welcome" in it. In the tutorial above it says "With just a few lines, the end result is already much better, with the “Welcome” line neatly placed between header, footer and columns!", except that I don't get that to show up. Here is the resulting source of my page: <!-- begin module:MyModule/views/templates/front/display.tpl --> <!-- begin [PATH TO WEBROOT REMOVED IN THIS EXAMPLE]/prestashop/modules/MyModule/views/templates/front/display.tpl --> Welcome to my shop! <!-- end [PATH TO WEBROOT REMOVED IN THIS EXAMPLE]/prestashop/modules/MyModule/views/templates/front/display.tpl --> <!-- module:MyModule/views/templates/front/display.tpl --> Apparently it doesn't even add body tags. If I add this to my .tpl file, I get a least header and footer, but leftColumn ist not being displayed either: {extends file='page.tpl'} {block name="page_content"} <p>Welcome to my shop!</p> {/block} Can anyone tell me what I am dong wrong? Or if indeed the tutorial is missing some info, what do I need to put into my display.tpl to get all shop columns? Many thanks for your help! P.
  3. Hi Sampsonzak, I would not recommend that you use the fix I posted above, as it did not solve the source of the problem, just fix some symptoms. If I remember well, the source of the problem was in a javascript not loading in IE. For us this javascript was part of the Newsletter Pro plugin. i suggest you look at the javascript console of Internet Explorer, there it may tell you what javascript is causing problems, if this is in fact the same problem you are having. Best regards, p.
  4. Our problem was due to the module Newsletter Pro which now has received an update to version 4.8.6 which solves our problem.
  5. Possibly part of the same problem we get reposts that the final "order" button isn't working for these same customers. There too the POSTing is done via Javascript. In my opinion the "add to cart" and "place order" buttons are among the most important buttons in the shop and should be as compatible as possible also with older browsers. I am trying to gather more info about the customer PC system on which the error occurs, we can currently only reproduce it on Internet Explorer on Windows 10. Not the most modern setup, however, customers who can't order are always right 🙂 Any help or pointers would be much appreciated! P.
  6. +++ EDIT September 2019 ++++ Don't apply the "fix" described below in PHP, since it just fixes some symptoms (not all) and is not a solution to the source of the problem. You probably have a javascript error somewhere, preventing correct execution of another script. Most probably this error is due to an incompatibility of a module/plugin. +++ END EDIT +++ On our installation of PS 1.7.4.4 we got reports of some customers, that they could not add products to the cart. A click on the button "Add to cart" took the customer to the view of the cart contents which said "no items in cart" or something like this. The modal dialog "product added to cart" we ourselves usually see at this point with the option to continue shopping or go to checkout was not appearing. The customer was using Windows 10 with the "lastest version of Firefox" but we could only duplicate this faulty behaviour with Internet Explorer on Windows 10. The option to "disable ajax" in the shopping cart module settings did not solve this problem. Finally we discovered that in controllers/front/CartController.php around line 231 this condition was failing: if (Tools::getIsset('add') || Tools::getIsset('update')) { $this->processChangeProductInCart(); } On the faulty system the POST values did not contain the variables add=1 action=update which were being POSTed on a setup where adding to cart was working for us as expected. It seems that in themes/core.js around line 1753 these values are added via javascript (see last line): $body.on('click', '[data-button-action="add-to-cart"]', function (event) { event.preventDefault(); if ((0, _jquery2['default'])('#quantity_wanted').val() > (0, _jquery2['default'])('[data-stock]').data('stock') && (0, _jquery2['default'])('[data-allow-oosp]').data('allow-oosp').length === 0) { (0, _jquery2['default'])('[data-button-action="add-to-cart"]').attr('disabled', 'disabled'); } else { var _ret = (function () { var $form = (0, _jquery2['default'])(event.target).closest('form'); var query = $form.serialize() + '&add=1&action=update'; Our solution consisted in modifying /themes/YOURTHEME/templates/catalog/product.tpl to add two hidden fields with name="add" and name="action" around line 101: <form action="{$urls.pages.cart}" method="post" id="add-to-cart-or-refresh"> <input type="hidden" name="token" value="{$static_token}"> <input type="hidden" name="add" value="1"> <input type="hidden" name="action" value="update"> <input type="hidden" name="id_product" value="{$product.id}" id="product_page_product_id"> <input type="hidden" name="id_customization" value="{$product.id_customization}" id="product_customization_id"> In our previously functioning environment, these values are now posted twice, resulting in "add" and "action" becoming arrays, but it still seems to be working. These are the POSTed values token 93865fd2ed163bfa72111fcbe7a39xyz add […] 0 1 1 1 action […] 0 update 1 update id_product 4 id_customization 0 group[1] 25 group[5] 31 qty 1 Although we have resolved our immediate problem for now, we would prefer to understand why the add-to-cart-button doesn't degrade gracefully to still function on an older browser or system. As I stated above our customer was himself on the "current version" of Firefox (we were unfortunately not able to confirm the version number), so it definitely is not just a a problem of very old browsers. Any hints would be appreciated and if nothing else, maybe this will help someone stumbling upon the same issue.
  7. I have the same problem after upgrading from 1.6.0.9 to 1.6.1.18. You have to go to Admin -> Localization -> Countries and edit the address format there to include phone numbers again.
×
×
  • Create New...

Important Information

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