Hi,
In the application I am building (relating to travel), the user adds a number of items to their basket and prior to checkout is prompted for how many guests it relates to so I need to update the number of items of everything in their cart.
Is it possible to modify:
function setquantityitem($request) {
$quantity = $request->getVar('quantity');
$product = $this->buyableFromURL();
if (is_numeric($quantity) && $product) {
$item = ShoppingCart::get_item($this->urlFilter());
if($quantity > 0){
if(!$item){
if($item = self::create_order_item($product,$quantity,self::get_clean_param_array($this->getRequest()->getVars()))){
$item->Quantity = $quantity;
self::add_new_item($item);
}
}
else{
ShoppingCart::set_quantity_item($item, $quantity);
}
}elseif($item){
ShoppingCart::remove_all_item($item);
return self::return_data("success","Item removed completely");//TODO: i18n
}
return self::return_data("success","Quantity set successfully");//TODO: i18n
}
return self::return_data("failure","Quantity provided is not numeric");//TODO: i18n
}
static function set_quantity_item($existingitem, $quantity) {
if ($existingitem) {
$existingitem->Quantity = $quantity;
$existingitem->write();
}
}
To update the quantity of every item in the users cart?