keithg

add to cart in ajax in prestashop 1.7

javascript var pid = $(‘#product_id’).val(); $.ajax({ url : url+’&action=savecustomdataAction’, type : “POST”, data : { customdata : customdata, qty : 1, pid : pid }, success : function(response) { if(response.message == true) { $(‘#addtocart_form’).submit(); } } });   Tpl file <script> var url =”{url entity=’module’ name=’appcustomizer’ controller=’ajaxfunc’ params = []}”;...Read more …
keithg

Use namespace in module when you want to display products.

use PrestaShop\PrestaShop\Adapter\Category\CategoryProductSearchProvider; use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever; use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter; use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever; use PrestaShop\PrestaShop\Adapter\Translator; use PrestaShop\PrestaShop\Adapter\LegacyContext; use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; use PrestaShop\PrestaShop\Core\Product\Search\SortOrder; //Code to get the products $RESULTS == From query results $blocks_for_template = []; $products_for_template = []; $assembler = new ProductAssembler($this->context); $presenterFactory = new ProductPresenterFactory($this->context); $presentationSettings = $presenterFactory->getPresentationSettings(); $presenter = new...Read more …