Forums / General Questions / Add a product to the cart from a custom page?

Add a product to the cart from a custom page?

Locked

Views: 640

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
21 Sep 2009, 3:35 PM
#1
refreshmentshop avatar

refreshmentshop

New Zenner

Join Date:
Oct 2008
Posts:
21
Plugin Contributions:
0

Add a product to the cart from a custom page?

The site I'm currently working on has an optional scheme the customer can sign up for which requires a membership fee...

First the customer completes a 3 page wizard (Custom pages) the last of which automatically adds the membership fee (A hidden product) to their basket.

Initially I achieved this with:

<form name="multiple_products_cart_quantity" action="index.php?action=multiple_products_add_product" method="post" enctype="multipart/form-data">
  <input type="hidden" name="products_id[123]" value="1" />
  <input type='submit' name='submit' value='Continue' />
</form>

The problem is if the customer mistakenly goes back to the previous page it will add the fee again...

What I'd like to do, is only allow 1 membership fee to be added at any one time. I think the onetime_membership_charge mod does this at sign up with:

// bof push membership product to cart webomat

    $my_membership_fee = MY_MEMBERSHIP_FEE;

    $sql = "insert into " . TABLE_CUSTOMERS_BASKET . "
    (customers_basket_id, customers_id, products_id, customers_basket_quantity, customers_basket_date_added)
	values ('','" . (int)$_SESSION['customer_id'] . "', $my_membership_fee, '1', '" . date('Ymd') . "')";

    $db->Execute($sql);

// eof push membership product

This doesn't seem to work if I just drop the code into my custom page (and yes, I've defined MY_MEMBERSHIP_FEE etc...).

I'm guessing I might need to include another file to access the database in this way, any ideas? :dontgetit

23 Sep 2009, 10:46 AM
#2
refreshmentshop avatar

refreshmentshop

New Zenner

Join Date:
Oct 2008
Posts:
21
Plugin Contributions:
0

Re: Add a product to the cart from a custom page?

Solved it, by setting 'Product Qty Maximum' to 1 in the product editor... simple huh.

Watch out for a bug with that mod(onetime membership charge). It hides the quantity box of a product in your cart... the trouble is, this must offset the array, as the update quantity button updates the products with the quantity of the product above them... Very bad:blink:

I got round this by using css to hide the box instead, not ideal but much safer.