Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Add A Product To The Cart Using A Link Rate Topic   - - - - -

 
  • lparodi
  • Member
  • Trial users
  • Join Date: 08-Dec 14
  • 46 posts

Posted 23 February 2016 - 04:14 PM #1

Hello,

I'm developing a "decision tree" using d3.js to give the users the opportunity to choose the right product based on his/her needs.

What I want to do is to add a link to the last leaf of the tree to permit to add the proper product to the cart.

 

Please have a look at the attached image to better understand.

 

Thanks

Luca

Attached Files

  • Attached File  tree.jpg   35.06KB   1 downloads


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21181 posts

Posted 24 February 2016 - 08:34 AM #2

If the link will be used in CS-Cart, you can use the following code:

<a href="{"checkout.add..244"|fn_url}" class="cm-post cm-ajax">{__('add_to_cart')}</a>

where 244 is the ID of the required product


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • lparodi
  • Member
  • Trial users
  • Join Date: 08-Dec 14
  • 46 posts

Posted 24 February 2016 - 10:01 AM #3

Hello,

thank you for your help.

The link is used inside an html block.

I have tried all these options but none of them works

 

<a href="{checkout.add..1|fn_url}" class="cm-post cm-ajax">PRODUCT LINK</a>

<br>
 <a href="{'checkout.add..1'|fn_url}" class="cm-post cm-ajax">{__('add_to_cart')}</a>
 <br>
 <a href="{checkout.add..1|fn_url}" class="cm-post cm-ajax">{__('add_to_cart')}</a>
 <br>
 <a href="{"checkout.add..244"|fn_url}" class="cm-post cm-ajax">{__('add_to_cart')}</a>

 

I get these errors depending on which link I click

 

ErrorOops, something went wrong (Forbidden). Please try again.

or

POST http://localhost/projects/rf_shop2/%7Bnet::ERR_CONNECTION_RESET



 
  • lparodi
  • Member
  • Trial users
  • Join Date: 08-Dec 14
  • 46 posts

Posted 24 February 2016 - 10:02 AM #4

Hello,

thank you for your help.

The link is used inside an html block.

I have tried all these options but none of them works

 

<a href="{checkout.add..1|fn_url}" class="cm-post cm-ajax">PRODUCT LINK</a>

<br>
 <a href="{'checkout.add..1'|fn_url}" class="cm-post cm-ajax">{__('add_to_cart')}</a>
 <br>
 <a href="{checkout.add..1|fn_url}" class="cm-post cm-ajax">{__('add_to_cart')}</a>
 <br>
 <a href="{"checkout.add..1"|fn_url}" class="cm-post cm-ajax">{__('add_to_cart')}</a>

 

I get these errors depending on which link I click

 

ErrorOops, something went wrong (Forbidden). Please try again.

or

POST http://localhost/projects/rf_shop2/%7Bnet::ERR_CONNECTION_RESET

 Sorry the 244 is replaced with 1 that is the actual product code



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21181 posts

Posted 24 February 2016 - 03:34 PM #5

You should use HTML block with SMARTY support. Please try


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • lparodi
  • Member
  • Trial users
  • Join Date: 08-Dec 14
  • 46 posts

Posted 26 February 2016 - 10:33 AM #6

Hello,

using a html block with Smarty support, the add to cart modal window appear, but the cart doesn't update (the number of itmes in the cart doesn't change) until I manually refresh the page.

Seems that the product is added correctly to the cart, but the cart content is not refreshed.



 
  • lparodi
  • Member
  • Trial users
  • Join Date: 08-Dec 14
  • 46 posts

Posted 26 February 2016 - 11:06 AM #7

I  noticed that there are some other relevant fields, but I don't know how to add them to the href link.

 

The most interesting are:

 

<input type="hidden" name="appearance[show_add_to_cart]" value="1" />

<input type="hidden" name="result_ids" value="cart_status*,wish_list*,checkout*,account_info*" />

 

I have tried something like this but doesn't work. Keeps on adding the prodcut to the cart but it doesn't refresh the number of contained items.

 

<a href="{"checkout.add..1"|fn_url}&result_ids=cart_status*,wish_list*,checkout*,account_info*&appearance[show_add_to_cart]=1" class="cm-post cm-ajax">NEW LINK</a>

 

Here the complete form

 

<form action="http://localhost/projects/rf_shop2/"method="post" name="product_form_1" enctype="multipart/form-data" class="cm-disable-empty-files  cm-ajax cm-ajax-full-render cm-ajax-status-middle ">
<input type="hidden" name="result_ids" value="cart_status*,wish_list*,checkout*,account_info*" />
<input type="hidden" name="redirect_url" value="index.html?dispatch=categories.view&amp;category_id=3" />
<input type="hidden" name="product_data[1][product_id]" value="1" />
<div class="ty-grid-list__image" id="container_id_1"><div class="quick-add" id="add_to_cart_1"><div class="cm-reload-1 " id="add_to_cart_update_1">
<input type="hidden" name="appearance[show_add_to_cart]" value="1" />
<input type="hidden" name="appearance[show_list_buttons]" value="" />
<input type="hidden" name="appearance[but_role]" value="action" />
<input type="hidden" name="appearance[quick_view]" value="" />
<button id="button_cart_1" class="ty-btn__primary ty-btn__big ty-btn__add-to-cart cm-form-dialog-closer ty-btn" type="submit" name="dispatch[checkout.add..1]" >Add to cart</button>



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21181 posts

Posted 26 February 2016 - 03:33 PM #8

OK. I got it. Use the following code:

<a data-ca-target-id="cart_status*,wish_list*,checkout*,account_info*" href="{"checkout.add..244"|fn_url}" class="cm-post cm-ajax">{__('add_to_cart')}</a>

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • lparodi
  • Member
  • Trial users
  • Join Date: 08-Dec 14
  • 46 posts

Posted 29 February 2016 - 09:34 AM #9

Hi thank you for the effort you put to solve the issue, but it doesn't work for me.

I have used a block with smarty support and just changed the product code, and basically I have the same behaviour as before.

The number of products in the cart is not updated, even if the product has been added.

Does it works for you ?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21181 posts

Posted 29 February 2016 - 01:14 PM #10

Just tested. Additional class is required. Please try

<a data-ca-target-id="cart_status*,wish_list*,checkout*,account_info*" href="{"checkout.add..244"|fn_url}" class="cm-post cm-ajax cm-ajax-full-render">{__('add_to_cart')}</a>

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • lparodi
  • Member
  • Trial users
  • Join Date: 08-Dec 14
  • 46 posts

Posted 29 February 2016 - 03:05 PM #11

No luck. I have also tried on an older cs-cart version, but it doesn't work for me.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21181 posts

Posted 01 March 2016 - 08:17 AM #12

No luck. I have also tried on an older cs-cart version, but it doesn't work for me.

 

Works for me. Just tested. Make sure that the cm-ajax-full-render class is added and clear the cache. It should work


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 

Posted 12 March 2017 - 04:26 PM #13

Just tested. Additional class is required. Please try

<a data-ca-target-id="cart_status*,wish_list*,checkout*,account_info*" href="{"checkout.add..244"|fn_url}" class="cm-post cm-ajax cm-ajax-full-render">{__('add_to_cart')}</a>
Is there anyway to have this work with out having the popup that says continue shopping/view cart?

 

Posted 12 March 2017 - 04:37 PM #14

No luck. I have also tried on an older cs-cart version, but it doesn't work for me.


You are using the product code witch is why it isn't working, you have to use the product_id for it to work.

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21181 posts

Posted 13 March 2017 - 07:23 AM #15

Is there anyway to have this work with out having the popup that says continue shopping/view cart?

 

Unfortunately, no. Additional code changes are required


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • happyhare
  • Advanced Member
  • Members
  • Join Date: 11-Jun 14
  • 56 posts

Posted 22 March 2017 - 10:38 AM #16

Is there a way to use this code to add multiple products. For example

<a data-ca-target-id="cart_status*,wish_list*,checkout*,account_info*" href="{"checkout.add..244,245,246,247"|fn_url}" class="cm-post cm-ajax cm-ajax-full-render">{__('add_to_cart')}</a>

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21181 posts

Posted 22 March 2017 - 02:11 PM #17

Is there a way to use this code to add multiple products. For example

<a data-ca-target-id="cart_status*,wish_list*,checkout*,account_info*" href="{"checkout.add..244,245,246,247"|fn_url}" class="cm-post cm-ajax cm-ajax-full-render">{__('add_to_cart')}</a>

 

Unfortunately, no


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • teosu
  • Senior Member
  • Members
  • Join Date: 09-Oct 14
  • 787 posts

Posted 27 December 2017 - 03:25 PM #18

+question

i have ajax request like this in categories page.

<a class="cm-ajax cm-post cm-ajax-full-render" data-ca-scroll=".ty-mainbox-title" data-ca-target-id="product_filters_*,products_search_*,category_products_*,product_features_*,breadcrumbs_*,currencies_*,languages_*,selected_filters_*,cp_category_title,cp_category_footer,select_attr" href="dispatch=categories.select_attr&amp;brand=750" rel="nofollow">extra info</a>

if i use regisrty display in php rendering that block. but i want render every target id without display assign

what can i do ?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21181 posts

Posted 28 December 2017 - 07:04 AM #19

+question

i have ajax request like this in categories page.

<a class="cm-ajax cm-post cm-ajax-full-render" data-ca-scroll=".ty-mainbox-title" data-ca-target-id="product_filters_*,products_search_*,category_products_*,product_features_*,breadcrumbs_*,currencies_*,languages_*,selected_filters_*,cp_category_title,cp_category_footer,select_attr" href="dispatch=categories.select_attr&amp;brand=750" rel="nofollow">extra info</a>

if i use regisrty display in php rendering that block. but i want render every target id without display assign

what can i do ?

 

In this case replace display function with

return array(CONTROLLER_STATUS_OK, 'categories.view?category_id=123');

where 123 - is the ID of required category page


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)