I have created quick order functionality on custom page layout .
Process like below:
customer find product in textbox and display matching products in autocomplete.In autocomplete result displays product-name,image and add to cart button.when I click add-to-cart button ,ajax call in custom created controller and I created code for programmatically add-to-cart product.Product add to cart successfully via my ajax code but mincart not render on top but when I refresh page then it displays products in minicart.
Anything missing in this process ? And How to render minicart in controller OR Anyone tell me where is code in magento 2 of minicart render after add to cart ajax ? I need a hint for this.please suggest me
1 Answer 1
You need to create the file module_dir/etc/frontend/sections.xml with this content:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
<action name="your/controller/action">
<section name="cart"/>
</action>
</config>