Jump to content

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

Adding Product To Cart Remotely Rate Topic   * * * * * 1 votes

 
  • Takestock
  • Senior Member
  • Members
  • Join Date: 08-Nov 13
  • 483 posts

Posted 05 April 2014 - 07:54 AM #21

It's going to checkout.checkout and then it's finding the cart is empty. Do your require https for your checkout? If you add under http and the go to checkout under https, then the cart may not have any contents. I would have to add some diagnostics to figure out what's happening at your site and I'm sorry, but I don't have time to investigate site specific issues right now.

Thanks for the reply, I turned off the Https in checkout and tested but it still did not work, This is not essential to me but it would be a great addition, I will revisit it when I have a few €s to get you to fix it.

Alan

 

Posted 29 April 2014 - 08:14 PM #22

Thanks for the code.

Got this working for a client.

A few changes:

if ( !defined('AREA') )  die('Access denied');

should be:

if ( !defined('BOOTSTRAP') )  die('Access denied');

app/addons/my_changes/frontend/checkout.pre.php

should be

app/addons/my_changes/controllers/frontend/checkout.pre.php

Jeremy
Requin Creative Group
CS-Cart License | CS-Cart Addons


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11428 posts

Posted 29 April 2014 - 10:53 PM #23

yep

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 

Posted 15 May 2014 - 11:50 AM #24

Hi,

This works great also in 4.1.3

But is it possible to add "virtual" product to the basket?

We have an external shop from our manufacturar, we would like that if someone ad an product to this cart, that is product will be added to cs-cart shoppingcart (while this product not excist in cs-cart)

 

Posted 15 May 2014 - 11:52 AM #25

It must the also import the price from the external site

 
  • mmovies
  • Member
  • Members
  • Join Date: 30-Jul 13
  • 22 posts

Posted 15 May 2014 - 04:32 PM #26

Hi Elektroshop,
I think it's possible if you put before the product into cscart and after this adding by put it to cart directly.
To put the I suggest you to do it in jquery with the curl connexion and after in the remote store and the end of of the add
to redirect the customer to the remote checkout...
But carefully don't do this "add product" ouside from curl connexion because you'll break your security base.
Hope this answer could help you could use CSCART_api script and find in this forum.
Regards
Mmovies

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11428 posts

Posted 15 May 2014 - 06:12 PM #27

You would have to pass a lot more information to have it create products on the fly. This little interface was not designed with that intent.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • helmi_pts
  • Member
  • Trial users
  • Join Date: 14-Mar 12
  • 39 posts

Posted 07 July 2014 - 07:54 AM #28

I tried this script on CS Cart 4.1.4; adding multiple products (e.g. http://bookcafe.com....967-369-220-0@1) but its not working.

Only the first product code in the URL string is added to cart, and item quantity is the sum of both product.

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11428 posts

Posted 07 July 2014 - 06:27 PM #29

I've updated the script located at http://www.ez-ms.com...out.pre.php.txt

It should work in V4 as it is and with a couple of adjustments near the top, V3 also. However I did simply edit in a text editor to update it to the current version but it has NOT been tested. However, it is running well at the client site where it was originally developed for.

Your mileage may vary.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • helmi_pts
  • Member
  • Trial users
  • Join Date: 14-Mar 12
  • 39 posts

Posted 13 August 2014 - 02:16 AM #30

Thanks tbirnseth, everything is perfect; though please advise the correct syntax for this line:

if( empty($product_id) ) // Try option inventory
   $product_id = db_get_field("SELECT product_id FROM ?:product_options_inventory WHERE product_code=%s", $product_code);

Should it be "WHERE product_code=?s" ?

If i use the original code, any products with invalid product id will produce a "store is closed" message. So I change it to product_code=?s

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11428 posts

Posted 13 August 2014 - 02:35 AM #31

Yes, you are correct. It should be '?s' versus '%s'.
I will update my source and thee source pointed to by the link.

Good catch.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 

Posted 19 November 2014 - 04:04 PM #32

Hi tbirnseth and thank you for posting this very great solution. However as one of the users also pointed out, i'm getting an empty cart when i try to checkout. What i found out is that it only works if there is already an existing product in the cart. The question now is that is there a workaround for this? i did a mupltiple product by the way.

Thanks,
Mark

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11428 posts

Posted 19 November 2014 - 09:01 PM #33

There have been several publications of this free code snippet. Not knowing what you have it is hard for me to guess.
There should be no restriction on whether the cart is empty or not. I use this extensively on some of my client sites for quickly adding products to checkout from a blog and then taking the customer there to complete the process.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 

Posted 23 November 2014 - 01:48 PM #34

Hi tbirnseth,

This is what i have: http://www.ez-ms.com...out.pre.php.txt i think this is also what you provided from the previous post. I already disabled https for testing purposes and i'm still getting the same result.

Usage:

I used your script to provide a "one time offer" feature in our store.

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11428 posts

Posted 24 November 2014 - 12:45 AM #35

I'd need a bit more info.. I.e. single or multiple products? I've not been able to reproduce any requirement for already having items in the cart.
You might try changing:
    if (empty($_SESSION['cart'])) {
        fn_clear_cart($_SESSION['cart']);
    }
to
    if (empty($_SESSION['cart'])) {
	    $_SESSION['cart'] = array();
        fn_clear_cart($_SESSION['cart']);
    }

If that resolves the problem, please let me know and I'll update the public source.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 

Posted 24 November 2014 - 11:41 AM #36

Hi tbirnseth,

Its for a multiple product checkout. I used this link internally.
<a href="<your_domain.com>?dispatch=checkout.remote_checkout.prod_code1@3|prod_code2@1&cc=<coupon_code>">Your link name<a>
unfortunately adding this inside the condition
$_SESSION['cart'] = array();

didn't resolve the issue. If i understand correctly, you are setting an empty array into the cart session. i cleared cache, template cache and still getting empty cart.

Thanks,
Mark

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11428 posts

Posted 24 November 2014 - 07:29 PM #37

I'll try to reproduce. However would suggest you not use the 'cc' parameter (conflicts with the clear cache parameter) and instead use 'c_code'.

Basically if the $_SESSION['cart'] is empty (i.e not set or equals array(), false, zero or other non-cart value) then set it to 'array()' and call the function to clear the cart which will do some initialization (I.e. if the user is logged in, uses their profile info, etc.). If it's already set, then it just points to it and uses is.

It then goes on to process the products.

You are not getting any kind of notification (either an error or notification of success)?

What happens if you use 'remote_add' instead of 'remote_checkout'? Do you see the items in the cart then?

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11428 posts

Posted 24 November 2014 - 10:38 PM #38

Unfortunately, I'm not able to reproduce this using the following URL (a cs-cart demo store products). Have you tried without the coupon code?

XX.com?dispatch=checkout.remote_checkout.U0012O5AF0@3|G0017HS88V@2|H0148VPS1T

It shows the proper number of products in the cart with the specified quantities. I didn't have any valid coupons setup so I didn't test with that. But even if using the clear_cache parameter (cc), it shouldn't affect the user's session data.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 

Posted 24 November 2014 - 11:28 PM #39

The only notification i get is "Your cart is empty, so you cannot proceed to checkout". i tried switching to remote_add, unfortunately im still getting the same result. i also set the coupon code to blank and used c_code as well but still the same.

You can reproduce the error by putting the link tag in the checkout.complete page. I'm using this internally that's why it's in that page.

The structure of my link tag is like this:

<a href="http://localhost/project_name/index.php?dispatch=checkout.remote_add.{$product_codes}">Checkout Now<a>

Thanks,
Mark

 

Posted 24 November 2014 - 11:51 PM #40

Update:

It works now! :) the issue is on my end, the structure of my files. i missed putting the frontend folder inside the controllers folder in my changes folder. i deeply apologize for that. im so sorry for taking much of your time. but i really do appreciate you for taking the time on answering my questions. tbirnseth=life saver.

Thanks,
Mark