Post by ogomo » Sat Feb 11, 2012 6:07 am

I'm trying to add a form to the shipping page at checkout as a way to up-sell a particular product.

I created the product just like I would any other product with several options. I then copied the form code found on that product's page, to the Shipping Page at checkout.

I'm able to get the form to display on the shipping info page without a problem. However, when I choose an option and click the "Add To Cart" button, I get the following warning displayed in the Cart Module :

Code: Select all

Notice: Undefined index: product_id in /catalog/controller/module/cart.php on line 118Notice: Undefined index: quantity in /catalog/controller/module/cart.php on line 118
The form code I am adding is:

Code: Select all

<form action="http://mysite.com/index.php?route=checkout/cart" method="post" enctype="multipart/form-data" id="product">
<select name="option[432]">
<option value="1084">Option 1</option>
<option value="1085">Option 2</option>
<option value="1086">Option 3</option>
<option value="1087">Option 4</option>
</select>
<a id="add_to_cart" class="button">
<span>Add to Cart</span>
</a>
<input type="hidden" name="product_id" value="580">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="redirect" value="http://mysite.com/index.php?route=product/product&product_id=580">
</form>
I'm adding it to /catalog/view/theme/mytheme/template/checkout/shipping.tpl so that it shows up in between the shipping address block and the shipping method block.

Also, I don't know if this matters, but I'm using OC 1.4.9.4.

Any help would be appreciated!!

New member

Posts

Joined
Thu Aug 04, 2011 1:35 am

Post by straightlight » Tue Feb 14, 2012 1:55 am

Could you post the array of the line 118 of catalog/controller/module/cart.php file ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by ogomo » Tue Feb 14, 2012 2:19 am

Line 118 of catalog/controller/module/cart.php is:

Code: Select all

$this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option);
I'm not entirely sure why this warning shows up. The code I'm using is the same code from the product page, so I can't imagine why it isn't working correctly.

New member

Posts

Joined
Thu Aug 04, 2011 1:35 am

Post by straightlight » Tue Feb 14, 2012 2:22 am

I see. Could you post the file as an attachment ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by ogomo » Tue Feb 14, 2012 2:39 am

Again, the attached file is the one found in: catalog/controller/module/cart.php

catalog/controller/module/cart.php


New member

Posts

Joined
Thu Aug 04, 2011 1:35 am

Post by straightlight » Tue Feb 14, 2012 2:46 am

By default, there's no such cart.php file within the catalog/controller/module folder but rather in the catalog/controller/checkout folder. If you do see it under the module folder, it is contributed.

Replace this line:

Code: Select all

$this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option);
replace with:

Code: Select all

if (!empty($this->request->post['product_id']) && !empty($this->request->post['quantity'])) {
    $this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option);
}
This should fix the problem.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by ogomo » Tue Feb 14, 2012 3:03 am

OK, that fixed the "Notice: Undefined index: product_id..." warning I was getting.
Now, when I click on the Add to Cart button, it doesn't add the product to the cart. It seems as if the form doesn't do anything (regardless of which option I choose in the drop-down).

New member

Posts

Joined
Thu Aug 04, 2011 1:35 am

Post by straightlight » Tue Feb 14, 2012 3:06 am

Would it be possible to provide your URL with the product you wish to add ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by ogomo » Tue Feb 14, 2012 3:10 am

This is the product that should be added from the form on the shipping page.
http://ogomo.com/index.php?route=produc ... uct_id=580

Add any other product to the shopping cart and go through the checkout process. When you get to the shipping page, I included the form from my original post.

BTW, I appreciate your help with this!!!

New member

Posts

Joined
Thu Aug 04, 2011 1:35 am

Post by straightlight » Tue Feb 14, 2012 3:17 am

I just tried with Chrome as I was able to add the product twice to the cart from the Add To Cart button. Is there something I have overlooked ?

I did found one problematic from the Chrome Inspector Element which reported this:

Code: Select all

Unsafe JavaScript attempt to access frame with URL http://ogomo.com/index.php?route=product/product&path=190&product_id=580 from frame with URL http://www.youtube.com/embed/51kVb3Q0ER8?rel=0. Domains, protocols and ports must match.
Perhaps this contribution would be the cause of prevention for adding the products for unknown reasons ? ;)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by ogomo » Tue Feb 14, 2012 3:21 am

Were you able to add the product from the product page http://ogomo.com/index.php?route=produc ... uct_id=580, or the checkout shipping page https://ogomo.com/index.php?route=checkout/shipping?

I don't have a problem with adding it from the product page. It's the checkout shipping page that is giving me the trouble.

I also tried (unsuccessfully) to do this in Chrome and IE9.

New member

Posts

Joined
Thu Aug 04, 2011 1:35 am

Post by straightlight » Tue Feb 14, 2012 3:26 am

I'm under the checkout page and I can still see the products to the cart. Although, I can't seem to find the Add To Cart button from your template you're referring from the checkout shipping page ... would it be possible to clarify that step ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by ogomo » Tue Feb 14, 2012 3:37 am

The form I'm trying to use is on the checkout page. It is in the yellow box under the shipping address, and above the shipping method boxes. See the attached screenshot, which shows the form I'm trying to use.
Delivery Information-142930.jpg

Delivery Information-142930.jpg (143.13 KiB) Viewed 2048 times

When I click the add to cart button next to the drop down box, it doesn't seem to want to actually add anything to the cart.

New member

Posts

Joined
Thu Aug 04, 2011 1:35 am

Post by straightlight » Tue Feb 14, 2012 4:27 am

I see. You're logged in to your site right now which is why you're able to see this option nor it was said on the above that only registered customers can use this option. If you right-click in Chrome and go to the Inspect Element option from that page, what does it report ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by ogomo » Tue Feb 14, 2012 5:48 am

Ok, I think I have it working now.
I moved the form above the shipping address field so now, in order, there is:
1) The form to add this product to the cart
2) The shipping address field
3) The shipping method field

The form that I was creating was included within the form that updates the shipping information. I think what happened is somehow the two forms were getting confused on where one began and the other ended...

In any event, I got it to work now exactly how I want it.

Thanks again for your help!!

New member

Posts

Joined
Thu Aug 04, 2011 1:35 am
Who is online

Users browsing this forum: Amazon [Bot] and 60 guests