Jump to content

Creating Sold Out Buttons


DMN31

Recommended Posts

Hey everyone,

 

Thought I'd ask the forum since I can't find it so far, but currently on our site for products we use a generic "Customize Now" button and it links off to the WHMCS product URL. If the product is available, they can customize and purchase, if it's not, they get the Product Out of Stock screen.

 

Is it possible to create a button that will display as Sold Out or something of that nature when Quantity Limit = 0? Seen people do it with other systems but not WHMCS so I wasn't sure.

 

Hopefully that makes sense.

 

Thanks everyone

Link to comment
Share on other sites

almost certainly possible - but which order form template are you wanting to try this with?

 

"Comparison" seems to disable the order now button, but I just did a quick test in "Modern", and you could do this with an if statement.

 

We're using the "Cart" form.

 

One thing to note, our HTML page with all of our products is an HTML page that doesn't link off to WHMCS until you hit the "Order Now" button. Not sure if that effects this at all. This is the page I was hoping was possible to have a button that could pick up on the inventory,

Link to comment
Share on other sites

our HTML page with all of our products is an HTML page that doesn't link off to WHMCS until you hit the "Order Now" button. Not sure if that effects this at all.

HTML pages won't render PHP code without telling the server to parse it for PHP (not recommended). It couldn't be done dynamically on those pages.

Link to comment
Share on other sites

ok, missed the bit that you were doing this external to whmcs...

 

there are two possible solutions that I can think of for this:

 

you'll either have to query the database - the link below will likely be out of date, but might be some guide if you want to go down this road..

 

http://forum.whmcs.com/showthread.php?9222-Display-Stock-for-Products&highlight=stock

 

or perhaps write a data feed to get the information for you...

 

http://docs.whmcs.com/Data_Feeds

 

the variable you're looking to use is $product.qty - if stock control is disabled, the variable won't exist; if enabled, it's value will be the stock level.

Link to comment
Share on other sites

ok, missed the bit that you were doing this external to whmcs...

 

there are two possible solutions that I can think of for this:

 

you'll either have to query the database - the link below will likely be out of date, but might be some guide if you want to go down this road..

 

http://forum.whmcs.com/showthread.php?9222-Display-Stock-for-Products&highlight=stock

 

or perhaps write a data feed to get the information for you...

 

http://docs.whmcs.com/Data_Feeds

 

the variable you're looking to use is $product.qty - if stock control is disabled, the variable won't exist; if enabled, it's value will be the stock level.

 

This actually was VERY useful since I had been considering pulling pricing in - thanks!

 

One question involving pulling pricing, is it possible to remove "USD" from the value it pulls? Currently it's pulling this in "$65.00 USD" but ideally I'd prefer "$65.00"?

 

I'm using this data feed:

 

<script language="javascript" src="feeds/productsinfo.php?pid=1&get=price

&billingcycle=monthly"></script>

Link to comment
Share on other sites

ok, missed the bit that you were doing this external to whmcs...

 

there are two possible solutions that I can think of for this:

 

you'll either have to query the database - the link below will likely be out of date, but might be some guide if you want to go down this road..

 

http://forum.whmcs.com/showthread.php?9222-Display-Stock-for-Products&highlight=stock

 

or perhaps write a data feed to get the information for you...

 

http://docs.whmcs.com/Data_Feeds

 

the variable you're looking to use is $product.qty - if stock control is disabled, the variable won't exist; if enabled, it's value will be the stock level.

 

Hey Brian,

 

Thank you for this, the data feed option actually answered a little site clean-up project I had been looking into! I wanted to begin pulling pricing in since managing price changes on 50-75 products each week was brutal.

 

My one question, currently using the below data feed script, it pulls in the price in this format: $65.00 USD - Is it possible to pull it in without the USD? Preferably without the cents (decimals) as well but USD is fine.

Link to comment
Share on other sites

  • 2 months later...
Hey Brian,

 

Thank you for this, the data feed option actually answered a little site clean-up project I had been looking into! I wanted to begin pulling pricing in since managing price changes on 50-75 products each week was brutal.

 

My one question, currently using the below data feed script, it pulls in the price in this format: $65.00 USD - Is it possible to pull it in without the USD? Preferably without the cents (decimals) as well but USD is fine.

 

 

I would like to know that as well:)

Link to comment
Share on other sites

apologies for not replying to DNM31 about this sooner, I must have missed the reply.

 

i'll go through a number of options...

 

if your WHMCS only uses one currency, then you could remove the line below (~line 74) from productinfo.php to just output the figure without any currency prefix or suffix ($ and USD):

 

$price = formatCurrency($price);

you could then add your currency symbol either in the feed or on the page where you are outputting the feed.

 

if you wanted to just display the amount with no prefix/suffix and with no decimal places, you would replace the above line with...

 

$price = number_format($price, 0);

if you want to keep the prefix ($ £ € etc), but remove the suffix (USD, GBP etc), add the line below after the formatCurrency line..

 

$price = str_replace("USD", "", $price);

if you were using multiple currencies, then you could either use multiple string replaces - only one should ever match..

 

$price = str_replace("USD", "", $price);
$price = str_replace("GBP", "", $price);

... or create an array and check against that..

 

$validsuffix = array("GBP", "USD", "EUR");
$price = str_replace($validsuffix, "", $price);

... or pull the suffixes from the appropriate database table...

 

$suffixresult = select_query("tblcurrencies","suffix");
$data2 = mysql_fetch_array($suffixresult);
$validsuffix = $data2['suffix'];
$price = str_replace($validsuffix, "", $price);

if you wanted to remove the prefix ($ £ € etc), but keep the suffix (USD, GBP etc), then you could query the database as above, but just replace "prefix" for "suffix" in the code.

 

$prefixresult = select_query("tblcurrencies","prefix");
$data3 = mysql_fetch_array($prefixresult);
$validprefix = $data3['prefix'];
$price = str_replace($validprefix, "", $price);

hope that helps. :)

Edited by brian!
Link to comment
Share on other sites

Just one last question from me.

 

-> How to add currency symbol in the feed?

We just want to get only prefix => "$100". No decimals and no suffix. Right now we have it this way:

 

$price = number_format($price, 0);

$price = str_replace("USD", "", $price);

 

 

Thanks

Link to comment
Share on other sites

Just one last question from me.

i'll hold you to that! :-P

 

-> How to add currency symbol in the feed?

We just want to get only prefix => "$100". No decimals and no suffix. Right now we have it this way:

 

$price = number_format($price, 0);

$price = str_replace("USD", "", $price);

you could do this by removing the formatCurrency line and using...

 

$price = "$" . number_format($price, 0);

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