All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Whmcs module and/or promo solution
I got help the last time I asked here so I might as well ask another question and hope for the best.
I am looking for a solution to offer discount on an order when chosing X amounts of products from a group/category.
Let me give an example;
I have 7 locations where I offer NAT service. The only options I have today is either do a bundle or offer a discount (percentage/price override) on every location.
What I’m looking for is to give the option to chose X number of locations, out of the 7, free of choice.
At checkout a Y% discount will be applied when/if there are X or more of the products in the basket.
No discount applied if the number of services is not reached.
Comments
I believe this can be done using hooks, you can hook your script to CartTotalAdjustment and manipulate total value. It contains array of services in cart so you can count length of array and return modified cart value.
Edit: Link to specific hook
And ofc, run your checks for product
That is my last resort, I was hoping someone already had done this
You're right: https://developers.whmcs.com/hooks-reference/shopping-cart/
My PHP is very rusty, but you should be able to use something along the lines of this:
https://pastebin.com/7urimh9q
@mikho did it workout ^ or do you need a module for this?
I’ve only saved the code for now.
Been busy preparing next location
In case it doesn't work out, feel free to ping me and we can sort it out. Happy to help, would be good to polish my PHP skills.
I was initially looking for an already made module but it seems that it has not been done before.
Your code is a good start, to make it "better" I would have all the settings visible "inside" WHMCS, to avoid editing the hook every time something needs to be changed.
I have done a module before so it is possible. I have planned to look at the code a few hours on Tuesday and a few hours on Wednesday. Hope I'm able to finish it before the release of next location.
module will be a bit complicated. Hook is the best way in this scenario.
Addon Module + hook.
You can add the hook in the addon module. Then you change the settings on the addon module page.
Quickly skimmed through the docs, doesn't seem too difficult to make this hook part of a module, create a MySQL table and dump the settings in there via the module settings. Would preferably store the combination of product id's and a discount, which would allow you to create different groups and apply different discounts on different product combinations (for example, your 128 and 256 MB plans).
@jetchirag & @solaire
Reporting back:
With some small adjustments, (discount per product added, if more than 3). I successfully changed the checkout price.
The recurring price is still the original amount, guess I need to combine it, with "OrderProductPricingOverride", where I can set the price per product....
Still looking/trying. Thanks for the help so far.
Quickly looked through OrderProductPricingOverride, it seems as if this callback is executed once per product and not for the whole bunch of products, so it'd be a bit harder to keep track on the total number of products that are currently in the users shopping cart.
However, you have access to the WHCMS session, which should provide you the contents of the cart (Session::get('cart')). This session should hold the array of products, which you can then use to apply the same logic as I've done last time.
You can do for each in cart and modify the value of each product using that hook
Finally found something that is working, running some tests to avoid any strange orders .
I would like to thank you in some way, do you have service with me? If so I will add some service credit for the help.
If you don’t have active service, let me know and I’ll add something for you.