Geting the current discount/label name

WPPizza – A Restaurant Plugin for WordPress Support General Support Geting the current discount/label name

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #43776

    Is there a way to retrieve the currently applied discount by its ID or by other means. I would like to display it in my custom sidebar. Also it would be nice if I could determine if there are more than one discounts at play and then just set a general label for discounts.

    Also it would be nice to be able to apply your own logic by turning on/off discount by discount ID if that makes sense.

    #43850
    Olly
    Admin & Mod

      > retrieve the currently applied discount by its ID…
      you could do something like this

      
      add_action('init', 'myprefix_discountids_applied');
      function myprefix_discountids_applied(){
      /***
      session are per blog if multisite
      ***/
      if(is_multisite()){
      global $blog_id;
      $session_key	= 'wppizza_cad_'.$blog_id;
      }else{
      $session_key	= 'wppizza_cad';
      }	
      $discount_ids = $_SESSION[$session_key]['discount'];
      /*
      now do something with the $discount_ids
      */	
      }
      

      >if I could determine if there are more than one discounts at play…
      the above will tell you if there’s one or more at play (as there will be none, one, or many id’s in that array)

      >apply your own logic…
      i suppose i could add a filter somewhere, however, if you want to apply your own logic you could also simply add your own discount(s) depending on your logic, using the wppizza_fltr_discount filter – which is essentially what the plugin does – along these lines

      
      add_filter('wppizza_fltr_discount', 'myprefix_apply_discounts',10, 3);
      function myprefix_apply_discounts($discountvalue, $session_items, $order_parameters){
      /* alter the current discount value as required */
      return $discountvalue;
      }
      
      #43868

      Thank you so much I will try these out!

      Cheers!

      #43869

      I wonder if there is a way with the myprefix_discountids_applied function to use the Id’s retrieved to simply turn off another discount by id.

      Say i want discount id 0 to be valid over id 2. Can I somehow from here tell the pluggin to deactivate discount with the Id 2 if 0 is in the array.

      In other words flick this on/off
      https://www.dropbox.com/s/xbaj6emyhmi9drs/Screenshot%202019-07-08%2012.18.21.png?dl=0

      #43870

      Oh I am sorry but the Cumulative apply in conjunction with other applicable discounts seems to achieve this so never mind the last comment

      #43871
      This reply has been marked as private.
      #43872

      Im sorry to be drowning you in posts like this but this seems to be a bug. I added an extra discount with the same properties as the one with the id 0 and then this works as expected. So It seems that for some reason that a id 0 gets left out if the Cumulative apply… checkbox is unchecked.

      cheers

      #43951
      Olly
      Admin & Mod

        >So It seems that for some reason that a id 0…
        what happens if you duplicate the one with id 0 and subsequently delete the one with ID 0 ?
        (there *might* be an empty() check somewhere – which would also return true if the id == 0 – that should be isset() instead ) ?

      Viewing 8 posts - 1 through 8 (of 8 total)
      • The topic ‘Geting the current discount/label name’ is closed to new replies.