Force users to pay online if they proceed a preorder

WPPizza – A Restaurant Plugin for WordPress Support General Support Force users to pay online if they proceed a preorder

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #53911
    nsrplanet
    Participant

      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,
      Nsrplanet

      #53923
      Olly
      Admin & Mod

        first 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 the wppizza_get_order_meta function referred to here https://docs.wp-pizza.com/developers/?section=preorder

        i.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 returned

        #53926
        nsrplanet
        Participant

          Thanks 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 428

          Warning: 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!

          #53948
          Olly
          Admin & Mod

            yeah, 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

          Viewing 4 posts - 1 through 4 (of 4 total)
          • The topic ‘Force users to pay online if they proceed a preorder’ is closed to new replies.