Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hooks, hacks, or JavaScript?


Recommended Posts

There are several things I like to conditionally hide ... for example, if an item is out of stock, I want to hide the 'Buy' button. If a customer puts an item in their shopping cart, and then increases the quantity to more than is available, I want to hide the 'Checkout' button.

Historically, I just hacked the code (yes, I hack the core code <hanging head in shame>) with an IF statement. Is there a better way?

I know that @burt has done something like this in one of his 28 days bundles, but he used JavaScript, and I know *nothing* about JavaScript.

I also have no idea how hooks work ( @burt , any chance someone could write up a tutorial on how hooks work, and how to use them? Or, a link to a resource that explains them?). I'm just a 'copy and paste' kind of guy.

TIA

Malcolm

Link to comment
Share on other sites

'Allow Checkout' is set to false. The 'Checkout' button still shows, and if you click on it, it takes you to the 'checkout_shipping' page. Clicking on the 'Continue' button takes you back to the shopping cart.

My point is, if there's not enough stock, don't even have a 'Checkout' button. Or a 'Buy' button.

Oh, and I also installed an add-on that displays the available stock quantity in the shopping cart, so the customer doesn't have to guess how many are available (yes, another core code hack <sigh>).

But, this doesn't answer my initial question ... What's the best way to hide these buttons? Hooks, hacks, or JavaScript?

M

Link to comment
Share on other sites

1 minute ago, ArtcoInc said:

'Allow Checkout' is set to false. The 'Checkout' button still shows, and if you click on it, it takes you to the 'checkout_shipping' page. Clicking on the 'Continue' button takes you back to the shopping cart.

My point is, if there's not enough stock, don't even have a 'Checkout' button. Or a 'Buy' button.

Ah, I hacked the code to force a redirect back to cart with a gentle reminder.ūüėŹ

Link to comment
Share on other sites

I too have items that say you must buy between x and y quantities. I have to insert MOQ and max in the quantity input fields. I don't see anyway I can do without hacking.

 

I am sure @burt is not restricting anybody from hacking. He ever mentioned that this is the beauty of openness of OSC codes.

Link to comment
Share on other sites

The answer is pretty simple;  you do whatever it takes to get it working as you want...

  • hook
  • ht module
  • content module
  • js / jquery
  • hack code

The less intrusive way...is...in my opinion...the better way.  

For the buy buttons, the simplest way is a piece of .js as a Hook.  1 file, done - set and forget. 

There is a hook bit that I posted just yesterday, scan back through my last few posts...

 

Link to comment
Share on other sites

Hi @ArtcoInc,

See this post on the subject of hiding buy buttons:

 

Peter

CE PHOENIX SUPPORTER

Support the Project, go PRO and get access to certified add ons

Full-time I am a C-suite executive of a large retail company in Australia. In my spare time, I enjoying learning about web-design.

Download the latest version of CE Phoenix from gitHub here

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...