Forum Replies Created
- AuthorPosts
-
Regarding the change limit:
How do I limit that? I have a pizza with 6 PRESELECTED toppings, but I only want the customer to be able to remove a maximum of 2 and/or add a maximum of 2.Small edit, adding $orderId to the hook as it doesn’t seem to be global.
$printerid=apply_filters('wppizza_gcp_filter_printerselect',$printers,$orderId); /*if no $printerid returned by filter, get the first printer*/ if(!isset($printerid) || $printerid == '') { $printerid = $printers[0]['id']; }
Yes, I’ve successfully selected different printers with this filter through the following function:
function wppizza_printerselect($printers,$orderId) { require(WPPIZZA_PATH.'classes/wppizza.order.details.inc.php'); $orderDetails=new WPPIZZA_ORDER_DETAILS(); $orderDetails->setOrderId($orderId); $order=$orderDetails->getOrder();/**all order vars**/ /******************************** simplify vars to us in template ********************************/ $location=$order['customer']['post']['ccustom1']['value'];//omit ['others'] here $delivery=$order['ordervars']['pickup_delivery']['value']; $deliveryarea=reset(explode(' ',$order['customer']['post']['wppizza-dbp-area']['value'])); if($delivery == 'Heimsending') { $koparray = Array(109,111,200,201,202,203); $hfjarray = Array(210,220,221,222,225); if(in_array($deliveryarea,$koparray)) { return searchForId('Dalvegur',$printers); } elseif (in_array($deliveryarea,$hfjarray)) { return searchForId('Dalshraun',$printers); } } else { if (strpos($location, 'Dalvegur')) { return searchForId('Dalvegur',$printers); } elseif (strpos($location, 'Dalshraun')) { return searchForId('Dalshraun',$printers); } } } add_filter('wppizza_gcp_filter_printerselect','wppizza_printerselect',10,2);
First it determines if the order is delivery, and if so, checks the post code and sends to the correct location. If not delivery, it sends the order print to the selected pickup location.
The searchForId function is made by me. In the cloud print settings you can change the display name of a printer, and the function uses that name to determine which printer is which. Got this working with a EPSON TM-T20II USB printer.
function searchForId($name, $array) { foreach ($array as $key => $val) { if ($val['displayName'] === $name) { return $val['id']; } } return null; }
Let’s put it this way
#1 has pepperoni, onions, mushrooms and peppers
#2 has ham, pineapple, cream cheese and baconcustomer wants to order half #1 + half #2, but exclude the cream cheese. If I just add the name of the pizza as an ingredient, they can’t do that, can they?
Okay, so there would be no way to remove/add toppings?
- AuthorPosts