Search the Community
Showing results for tags 'override cartcontroller'.
-
i try create a script that check a xml before add product in the cart. <?php class CartController extends CartControllerCore { /** * This process add or update a product in the cart */ protected function processChangeProductInCart(){ parent::initContent(); require (_PS_MODULE_DIR_.'/'.$this->module_name.'/controllers/admin/data.php'); require (_PS_MODULE_DIR_.'/'.$this->module_name.'/controllers/admin/data_v4.php'); require (_PS_MODULE_DIR_.'/'.$this->module_name.'/controllers/admin/language.php'); require (_PS_MODULE_DIR_.'/'.$this->module_name.'/controllers/admin/all.php'); $reference = Db::getInstance()->getValue('SELECT reference FROM '._DB_PREFIX_.'product WHERE id_product='.$product->id); $parameters=array( 'Operation' =>'ItemLookup' , 'ItemId' =>urlencode($reference) , 'ResponseGroup' =>'Medium' , ) $A=aws_request($parameters); foreach($A->Items->Item as $item){ $info[$i]['valor'] = $item->ItemAttributes-> ListPrice->Amount; $margemlucro = '1.'.Configuration::get('modulemarge'); $info[$i]['precofinal'] = $info[$i]['valor']*$margemlucro/100; $info[$i]['total'] = $item->OfferSummary->TotalNew; } if(( $info[$i]['total'] > 0) AND ($product['price'] >= $info[$i]['precofinal'])) { return true; }else{ if(($item->erro == TRUE) OR (empty($item))) return true; $produto= array('active' => 0); $execute = Db::getInstance()->update('product',$produto, 'reference' = $reference, $limit = 0, $null_values = false, $use_cache = true, $add_prefix = true); $this->errors[] = Tools::displayError('This product is no longer available, because we dont have more on stock, if you wish them, send us a email that we team will check and back with you soon possible.', false); return; } } } But is don't work. How i can check if this script is running on the website?
-
Hi, I'm limited in my php abilities and need some direction (prefer working example) of how I can have a function that adds two products from my catalog into the cart, one of the products is what the customer ordered the other is a custom item that needs to be added automatically. I currently do this thru a mod in the ajax-cart.js under the BlockCart module, it works to a point but at times it misses adding the second product - I need something that is a little more repeatable. I'm using cookies to do this and use the same cookies to make some other custom attribute changes such as custom text. thanks in advance to any help you can give. regards Andre