WPPizza – A Restaurant Plugin for WordPress › Support › General Support › Force users to pay online if they proceed a preorder
- AuthorPosts
- 5 February, 2021 at 1:26 pm #53911
Hey Olli,
first i would like to thank you for the this greate plug-in.
My problem is, i don´t find any option or methode, to force (non-logged) Customers to pay online if they proceed a preoder.
I find this filter “https://www.wp-pizza.com/topic/gateway-filter-frontend/” which i edited corresponding to my goal:add_filter( 'wppizza_filter_gateways_available', 'myprefix_filter_wppizza_gateways' ); function myprefix_filter_wppizza_gateways($gateways) { if($preorder){ unset($gateways['COD']);//gateway keys are always uppercase } return $gateways; }
unfortunately that does not work!
Thanks,
Nsrplanet6 February, 2021 at 1:34 am #53923first of all,
$preorder
is not an existing parameter/value in any event in this context, so this will never work .you probably want to use the
wppizza_filter_gateways_payment_options
filter to begin with https://docs.wp-pizza.com/developers/?section=gateway-filter-frontend
in conjunction with thewppizza_get_order_meta
function referred to here https://docs.wp-pizza.com/developers/?section=preorderi.e use
wppizza_filter_gateways_payment_options
and within that filter action get the preorder value useing ‘wppizza_get_order_meta’ function and do your conditionals depending on that meta value returned6 February, 2021 at 11:06 am #53926Thanks for your answer Olly,
Sorry, i have forget to define the variable in my exemple above. Here is my next try:add_filter('wppizza_filter_gateways_payment_options', 'my_custom_gateways_on_zero', 10 , 3); function my_custom_gateways_on_zero($gateway_objects, $order, $user_data){ $pluginSlug = 'wppizza_preorder'; $preorder = wppizza_get_order_meta($order['ordervars']['order_id']['value'], $pluginSlug, true ); if($preorder !='asap'){ foreach($gateway_objects as $id => $obj){ if($id !== 'COD'){ unset($gateway_objects->PAYPAL); } } } }
=>
Warning: get_object_vars() expects parameter 1 to be object, null given in /www/htdocs/xxx/xxx/wp-content/plugins/wppizza/classes/class.wppizza.gateways.php on line 428Warning: count(): Parameter must be an array or an object that implements Countable in /www/htdocs/xxx/xxx/wp-content/plugins/wppizza/classes/class.wppizza.gateways.php on line 428
Warning: Invalid argument supplied for foreach() in /www/htdocs/xxx/xxx/wp-content/plugins/wppizza/classes/class.wppizza.gateways.php on line 437
Note, that when the user choose a time slot for the preoder in the order page (so the value is not more ‘asap’), the order page will not be updated!
8 February, 2021 at 6:05 pm #53948yeah, this will not work actually , as the meta value only gets inserted into the db when actually submitting the order, not before.
other than doing some javascript listening to the onchange event in the preorder plugin input field perhaps , then forcing a reload of the page with the filter conditionally set so the COD option gets removed/added as required , i cannot really think of anything else here at the moment
- AuthorPosts
- The topic ‘Force users to pay online if they proceed a preorder’ is closed to new replies.