Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

checking basket before checkout with javascript


Dominos

Recommended Posts

Posted

Hi,

 

I need to check the basket just before customer can checkout (when he clicks in checkout button), with a javascript and show a message if the total sum quantity money is less than a number. I have the javascript but dont know how can do it and where in the code. Thx

Posted
Hi,

 

I need to check the basket just before customer can checkout (when he clicks in checkout button),  with a javascript and show a message if the total sum quantity money  is less  than a number. I have the javascript but dont know how can do it and where in the code. Thx

 

 

what about the people who have javascript disabled ?

Treasurer MFC

Posted
what about the people who have javascript disabled ?

 

 

There's already javascript in osc so I wouldn't worry about that. There's not many websites that don't use javascript.

Posted
There's already javascript in osc so I wouldn't worry about that. There's not many websites that don't use javascript.

 

true but most professional websites have alternatives for when customers do not use javascript.

besides, there is no need for it since the subtotal is already known by php in the cart.

Treasurer MFC

Posted

Are you wanting to stop the customer from buying or add a surcharge?? There are shipping modules that will allow you to charge different rates for different order values?

Posted

Hi again,

 

first, i have to say that my website is not public, is an ecommerce intranet website with authorized users only ( about 30 or so). The ecommerce have been modified as an intermediary between customers (departaments) and external providers through email. All prices have taxes included, and pay is made between departaments and providers.

 

what about the people who have javascript disabled ?

The people who have js disable maybe cant buy, so they must enable it.

 

 

Ive think in something like that but really dont know how:

 

<td width="100%" valign="top"><?php echo tep_draw_form('check_cart', tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL'), 'post', [b]'onSubmit="return my_javascript(param1,param2);"[/b]'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

 

Or something like javascript check in create_account.php

 

thx

Posted

I don't have time to look and see how to do it but you'd be best to make the check before the checkout procedure. I.e. as a function run from the 'go to checkout' button or a check on the first checkout page which will redirect the user back if there's not enough in their basket. You'll just piss them off if they get to the confirmation page then get rejected.

Posted

OK sorry for the previous unhelpful reply!

 

This is what I'd do. It's really simple!

 

In checkout_shipping.php (or whatever your first checkout page is) you'll find little bits of php that check there's actually something in the cart:

 

  if ($cart->count_contents() < 1) {
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

 

Just under this put something like:

 

    if ($cart->show_total() < 25.00) {
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

 

where 25.00 is the minimum order value.

 

This will redirect them back to their cart but you'll need to add a message somehow. (javascript popup maybe?)

Posted

Yes, very simple. :blink: .

 

Thank U mate, problem solved. Very easy and better than only js. :thumbsup:

 

 

OK sorry for the previous unhelpful reply!

 

This is what I'd do. It's really simple!

 

In checkout_shipping.php (or whatever your first checkout page is) you'll find little bits of php that check there's actually something in the cart:

 

 ?if ($cart->count_contents() < 1) {
? ?tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
?}

 

Just under this put something like:

 

 ? ?if ($cart->show_total() < 25.00) {
? ?tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
?}

 

where 25.00 is the minimum order value.

 

This will redirect them back to their cart but you'll need to add a message somehow. (javascript popup maybe?)

Archived

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

×
×
  • Create New...