On a custom page within Magento, I have a simple AJAX Post which passes a product ID to a php script:
jQuery.ajax({
url: 'https://www.mywebsite.com/test/add_to_basket.php',
type: "POST",
data: data,
success: function (data) {
,
error: function (data) {
}
});
Here is the add_to_basket php script:
$i = $_POST['i'];
require_once '../app/Mage.php';
umask(0);
Mage::app();
Mage::init('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
$session = Mage::getSingleton('customer/session');
$cart = Mage::getSingleton('checkout/cart');
$cart->init();
$cart->addProduct($i, 1);
$session->setCartWasUpdated(true);
$cart->save();
This works perfectly, however the mini cart doesn't update. I've read that I need to create a sections.xml file within etc/frontend like so:
<?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="[frontName]/[ActionPath]/[ActionName]">
<section name="cart"/>
</action>
</config>
However I'm not sure what the [frontName]/[ActionPath]/[ActionName] would be in my example. What is the best course of action?