WPPizza – A Restaurant Plugin for WordPress › Support › Code Snippets WPPizza v2.x (read only)
(Code Snippets for v3.x) › cart and order filter options
- AuthorPosts
- 13 June, 2014 at 5:58 pm #4068
the following filters allow you to pretty much change whatever options are set in the administration dynamically/programatically regarding the way things are calculated, displayed etc etc in the frontend shoppingcart, orderpages ,emails, payments …you get the idea
please note, you can do a lot of damage with this (as in wrongly calculating things or not displaying stuff correctly or stoping emails from being sent etc etc.
if you use it, do so at your own risk and *do* test things thoroughly ……
either way, as an example, if you have set discounts to generally apply in some shape or form, but do not want to apply any discounts between 14:00 and 18:00 for example, try the following
add_filter('wppizza_filter_order_summary_options','my_wppizza_options_filter'); function my_wppizza_options_filter($options){ /** filter options as required: for example, no discount between 14:00 and 18:00 **/ $currentTime=current_time('timestamp');/*get current time*/ $startTime = strtotime(date("Y-m-d").' 14:00:00');/*set starttime for no discount*/ $endTime = strtotime(date("Y-m-d").' 18:00:00');/*set endtime for no discount*/ /*set discount to 'none' if between those two times*/ if($currentTime>=$startTime && $currentTime<$endTime){ $options['order']['discount_selected']='none'; } return $options; }
there is another filter that can be applied in conjunction with this if needs be that would deal with session variables like so:
add_filter('wppizza_filter_order_summary_session','my_wppizza_session_filter'); function my_wppizza_session_filter($session){ /*do something with the session vars if needs be*/ return $session; }
- AuthorPosts
- The topic ‘cart and order filter options’ is closed to new replies.