Jump to content

How to mass update products to current price change


markc

Recommended Posts

Hi, I use Configurable Option Groups for my pricing structure and my registrar has an included price update for all TLD so the prices for my products and domains have been adjusted but how to I automatically apply these price changes to all my customers without having to click Save on every client product and domain as the admin user?

 

Note: I cannot use the included Bulk Pricing Updater module because it has it's own non-optional pricing adjustments. I can't use that method because it would completely mess up my Configurable Options pricing (or ignore them, I haven't been game enough to try the Updater module) and my domain prices have already been updated (some lowered, some increased) by the domain registrars module. All I want to do is mass update all users current pricing to whatever values are in the pricing tables without manually clicking Save on every clients product and domain page.

Link to comment
Share on other sites

13 hours ago, markc said:

All I want to do is mass update all users current pricing to whatever values are in the pricing tables without manually clicking Save on every clients product and domain page.

in practice, I think you should just have to create an array of service IDs (and you can determine in that array's creation whether it should only include active services) and then loop through that resulting array running the UpdateProductClient API on each ID and specifically using the autorecalc option.

as this would be updating the database, remember to back it up before running... just in case the resulting changes are not what you had in mind! 😲

Link to comment
Share on other sites

Thanks brian! (again), I looked at some docs and examples and fighting my way through trial by fire I got to this decade old search result...

The localAPI has to be used within a WHMCS script like a hook, addon or module, you cannot create standalone files using the localAPI function.

So is this still a thing in 2021? Is there no way to write a "simple" external standalone PHP script to interact with the WHMCS API?

If not would you be aware of the right database fields I could directly twiddle to simply tell WHMCS to auto update the price to whatever is the pricing tables?

I probably have to do this once or twice a year so it's worth trying to create a script/whatever compared to logging into 1000 users accounts and manually clicking on Save for every product and domain they might have. I'm rather shocked something so simple is going to this hard to achieve!

Link to comment
Share on other sites

9 hours ago, markc said:

So is this still a thing in 2021?

I would expect so - though I don't think that i've ever tried using the internal API outside of those options.

10 hours ago, markc said:

Is there no way to write a "simple" external standalone PHP script to interact with the WHMCS API?

if it were me, i'd probably run this in an admin widget (which is effectively a hook anyway) - that way you can run it as and when you need to.

10 hours ago, markc said:

If not would you be aware of the right database fields I could directly twiddle to simply tell WHMCS to auto update the price to whatever is the pricing tables?

my default position would nearly always be to write the database query myself rather than use the API (which are often just glorified SQL queries anyway) - though that's partially caused by getting my fingers burnt the first time I tried to use the API many years ago - it was bugged by an update and didn't work (with a large amount of time wasted trying to make it!)

however for something like this, even I would use the API - there would be at least 3 tables to query (tblhosting, tblhostingconfigoptions and tblpricing) and numerous calculation steps before you would get to the end value that would then be used to update the recurringamount value record in tblhosting... I think that writing your own solution for that rather than just using the API could be filed under "doable - but tedious". 🙂

10 hours ago, markc said:

I'm rather shocked something so simple is going to this hard to achieve!

well you have rather handicapped yourself by not wanting to use any of the existing off-the-shelf solutions. 😎

Link to comment
Share on other sites

Hmm, "not using off-the-shelf solutions". I'd argue that taking advantage of my domain registrars ability to auto update the list of TLDs (400+) along with updated pricing either up or DOWN (because of our AUD exchange rate fluctuations) is pretty well off-the-shelf. Also my use of Configurable Option Groups for about 30 bulk price tiers per websites, mailboxes and 1GB storage selections is arguably off-the-shelf too because it's part of the basic functionality WHMCS offers, and which I am grateful to take advantage of compared to 27,000 separate plans (30 x 30 x 30 possible combinations) to do the same thing versus essentially one single pay-as-you-grow plan.

Anyway I thought I'd be smart and try to at least update my domains by leaving the price at 0.00 but no, I get a popup saying there MUST BE some price or percentage INCREASE across selected domains. So that can't work, at all, because half my wholesale domain prices have decreased. There was also no way to autoselect all 400+ domains at once (no Select All option) so I wasn't too keen on risking RSI to click on 400 buttons anyway.

I also thought maybe I could copy the Bulk Updater addon module and hack away the 90% of it I don't need... nope, it's encrypted! 😞

Link to comment
Share on other sites

4 hours ago, markc said:

Hmm, "not using off-the-shelf solutions".

for this issue.

4 hours ago, markc said:

I also thought maybe I could copy the Bulk Updater addon module and hack away the 90% of it I don't need... nope, it's encrypted! 😞

well i've warned on here for many years about using the Bulk Pricing Updater with domains - it is extraordinarily buggy and, to my knowledge, has never been fixed - for services, it might be an option... for domains, I wouldn't touch it with three bargepoles strapped together. ⚠️

besides, I don't think the BPU handles configurable options in the sense you want it to - it's just a blunt knife pricing updater which doesn't take into account specific service configurations and just runs a straight SQL update query on the applicable services/addons/domains.

if it helps, Kian posted a hook to do this for *one* client - that would at least show you the basics of getting a list of services and using the relevant API call.... fundamentally, what you want to do isn't difficult to code, it's just the relevant testing of it that would be time-consuming.

Edited by brian!
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated