Guest Posted March 23, 2013 Posted March 23, 2013 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
multimixer Posted March 23, 2013 Posted March 23, 2013 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'])); My community profile | Template system for osCommerce - New: Responsive | Feedback channel
Guest Posted March 23, 2013 Posted March 23, 2013 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
multimixer Posted March 23, 2013 Posted March 23, 2013 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 My community profile | Template system for osCommerce - New: Responsive | Feedback channel
Guest Posted March 23, 2013 Posted March 23, 2013 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
Guest Posted March 23, 2013 Posted March 23, 2013 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?
multimixer Posted March 23, 2013 Posted March 23, 2013 Does the product has attributes? Is the products id at least correct? My community profile | Template system for osCommerce - New: Responsive | Feedback channel
Guest Posted March 23, 2013 Posted March 23, 2013 It has one product attribute, yeah the products_id is correct
multimixer Posted March 23, 2013 Posted March 23, 2013 If a product has attributes, it will always go to product info My community profile | Template system for osCommerce - New: Responsive | Feedback channel
Guest Posted March 23, 2013 Posted March 23, 2013 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.