Post by xaappx1 » Wed Dec 06, 2017 6:22 am

Hi guys,

I have a pretty custom site I want to build and want to do that 100% custom, but use the OC3 backend with all of it's available payment gateways, mods, etc.

the database will be in the OC3 format, and everything will work as a normal install except the front end (minus the checkout part).

So my question is... anyone know how to pass something from any html page into the OC cart so I can code the add to cart?

once I can figure out how to add something to cart from a page outside of OC3, I should be set.

thanks for your help in advance!

Newbie

Posts

Joined
Wed Dec 06, 2017 6:19 am

Post by IP_CAM » Thu Dec 07, 2017 3:15 am

Something like this would probably do the Job.
Ernie
---
Link Cart (Share Your Cart)
https://www.opencart.com/index.php?rout ... n_id=13731
---
Utimate Add To Cart via URL
https://www.opencart.com/index.php?rout ... n_id=21707
---
Add to Cart URL link + Multi Prod + Coupon (1.5/2.x/3.x)
https://www.opencart.com/index.php?rout ... n_id=11443
---
some more info on such:
http://forum.opencart.com/viewtopic.php?t=14960
---

Contact: jti@jacob.ch
---
Demos:
OpenCart LIGHT 1.5.6.5: http://www.openshop.li/light/
OpenCart V-PRO 1.5.6.5: http://www.velomech.ch/shop/
V-PRO Multi Theme View: http://www.openshop.li/shop/
---
Downloads:
Free Github OC Downloads: https://github.com/IP-CAM
1'900+ FREE OC Extensions from the world's largest Github OC Archive.
---
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by xaappx1 » Fri Dec 08, 2017 7:13 am

Thanks, but not really what I mean.

Essentially... how can I form a URL that can pass a product_id to add that product_id to cart?

thanks

Newbie

Posts

Joined
Wed Dec 06, 2017 6:19 am

Post by straightlight » Fri Dec 08, 2017 7:34 am

Incomplete question. From inside of Opencart or as an API?

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by xaappx1 » Fri Dec 08, 2017 11:25 pm

straightlight wrote:
Fri Dec 08, 2017 7:34 am
Incomplete question. From inside of Opencart or as an API?
Neither. A static HTML page. I just need to create a <FORM> to pass a product_id to the opencart shopping cart to add it to cart.

Newbie

Posts

Joined
Wed Dec 06, 2017 6:19 am

Post by straightlight » Fri Dec 08, 2017 11:32 pm

So, yes, an API. Followed is a post that can be you with this: viewtopic.php?f=128&t=172429&p=690535&h ... rt#p690535 . You first need to gather the query before passing it through your HTML form. You could use something like:

Code: Select all

$import = new import();

$product_info = $import->db->query("SELECT * FROM `" . DB_PREFIX . "product` WHERE `product_id = '" . (int)$_GET['product_id'] . "' AND `status` = '1'");
Then, on your HTML form:

Code: Select all

<form action="your_target_file">
<input type="hidden" name="product_id" value="<?php echo $product_info['product_id; ?>">
<?php echo html_entity_decode($product_info['name'], ENT_QUOTES, 'UTF-8'); ?>
</form>
Which will output the hidden product ID in the form and showing the product name, for example.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by xaappx1 » Sat Dec 09, 2017 9:37 am

Thanks, so it's passing it like this:

index.php?route=checkout/cart?product_id=1

?

Newbie

Posts

Joined
Wed Dec 06, 2017 6:19 am

Post by straightlight » Sat Dec 09, 2017 11:56 am

xaappx1 wrote:
Sat Dec 09, 2017 9:37 am
Thanks, so it's passing it like this:

index.php?route=checkout/cart?product_id=1

?
The GET parameter has been discussed many times on the forum in the past as it would not be suggested to do it this way without a token. There's an easier way to pass the product ID from a static HTML page. Simply link the catalog/view/javascript/common.js file from your HTML file and use the function: cart.add('product_id') which the product_id would be your captured product ID you'd like to pass to the POST parameter which would be already handled by the Ajax request from the JS file.

An example can be seen in the catalog/view/theme/default/template/product/product.twig file with this cart.add object.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member
Online

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: jonagoldapple and 38 guests