WPPizza – A Restaurant Plugin for WordPress › Support › General Support › Geting the current discount/label name
- AuthorPosts
- 2 July, 2019 at 10:17 am #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.
6 July, 2019 at 3:59 pm #43850> retrieve the currently applied discount by its ID…
you could do something like thisadd_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 thewppizza_fltr_discount
filter – which is essentially what the plugin does – along these linesadd_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; }
8 July, 2019 at 10:31 am #43868Thank you so much I will try these out!
Cheers!
8 July, 2019 at 11:19 am #43869I 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=08 July, 2019 at 11:40 am #43870Oh I am sorry but the Cumulative apply in conjunction with other applicable discounts seems to achieve this so never mind the last comment
8 July, 2019 at 2:38 pm #43871This reply has been marked as private.8 July, 2019 at 2:51 pm #43872Im 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
15 July, 2019 at 7:15 pm #43951>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 anempty()
check somewhere – which would also return true if the id == 0 – that should beisset()
instead ) ? - AuthorPosts
- The topic ‘Geting the current discount/label name’ is closed to new replies.