Create events.xml file in folder ‘Magemonkeys/Cartmodule/etc/frontend’ and use event ‘checkout_cart_product_add_after’. And paste the below code in it.
1 2 3 4 5 6 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="checkout_cart_product_add_after"> <observer name="addprice" instance="Magemonkeys\Cartmodule\Observer\AddPrice" /> </event> </config> |
And now create ‘AddPrice.php’ file in ‘Observer’ folder with the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?php namespace Magemonkeys\Cartmodule\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\App\RequestInterface; class AddPrice implements ObserverInterface { public function execute(\Magento\Framework\Event\Observer $observer) { $item = $observer->getEvent()->getData('quote_item'); $item = ( $item->getParentItem() ? $item->getParentItem() : $item ); $price = 50; // set custom price here $item->setCustomPrice($price); $item->setOriginalCustomPrice($price); $item->getProduct()->setIsSuperMode(true); } } ?> |
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-62846651f01b9658939712/] Create...
You can try below code to change local date to...
Step 1: First you need to add registration.php file in...
Step1 : Override message.js in current theme file on the...