Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

add to basket button


Guest

Recommended Posts

Hi

 

Just need bit of guidence on this, I have managed to get a add to cart button showing on my bestsellers.php page using the following coding

 

echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params
(array('action')) . 'action=buy_now'));

 

Only issue is, it don't add the product to the shopping cart, it goes to the shopping cart but says your shopping cart is empty

 

Kind regards

 

Ian

Link to comment
Share on other sites

Isn't it clear what the issue is?

 

Do you specify anywhere the products id ? How should the script know what to add to the cart?

 

Take an example from file products_new.php

 

tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']));

Link to comment
Share on other sites

Hi George

 

Thank you for replying back to me

 

I copied the code from the products_new page and pasted it in and changed to the following but is going to the product info page and not adding the product to the shopping cart

 

tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(FILENAME_BESTSELLERS, tep_get_all_get_params
(array('action')) . 'action=buy_now&products_id=' . $best_sellers['products_id'])));

 

The whole section of that code is below

 

'<a "href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $best_sellers['products_image'], $best_sellers['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . $best_sellers['products_name'] . '</a><br>' . $currencies->display_price($best_sellers['products_price'], tep_get_tax_rate($best_sellers['products_tax_class_id'])) . '<br>' .  tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(FILENAME_BESTSELLERS, tep_get_all_get_params
(array('action')) . 'action=buy_now&products_id=' . $best_sellers['products_id'])));

 

Am assuming it is because of the link being FILENAME_PRODUCT_INFO

 

What would that need to be changed to so that it adds the product to the shopping cart and not going to the product info page

Link to comment
Share on other sites

This here, won't go to product_info, unless the product has attributes or in case FILENAME_BESTSELLERS is defined as product_info.php

 

tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(FILENAME_BESTSELLERS, tep_get_all_get_params
(array('action')) . 'action=buy_now&products_id=' . $best_sellers['products_id'])));

 

You also need to make sure that $best_sellers['products_id'] has a value

Link to comment
Share on other sites

I checked the filenames.php and FILENAME_BESTSELLERS is pointing to bestsellers.php

 

How do I know or check that $best_sellers['products_id'] has a value

Link to comment
Share on other sites

When I do click the add to cart button and goes to the product info page, it does come up with products_id=48 in the address bar so guess it's products id is working ok, is that right?

Link to comment
Share on other sites

Ahh ok mates sense as the customer will need to choose the right attribute for them as the product has different sizes

 

Will leave it as is then

 

Thank you for replying and helping etc, really appreciate it

 

Ian

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...