Jump to content

PHP Shopping Cart - Return URL After Add to Cart not working


Recommended Posts

Hope someone can help

 

I used 'metro-webdesign.info' to create my desired site.  I am busy implementing a shopping cart which I am busy developing in php. 

 

When you click on Add to Cart, it sees and excecutes cart_update.php but never returns back to the shopping list, which is index.php.

 

I hope you understand...please help

        while($obj = $results->fetch_object())
        {
			echo '<div class="product">'; 
            echo '<form method="post" action="http://localhost/functions/#!/url=cart_update.php">';
			echo '<div class="product-thumb"><img src="img/products/'.$obj->product_img_name.'" width="100px"></div>';
            echo '<div class="product-content"><h3>'.$obj->product_name.'</h3>';
            echo '<div class="product-desc">'.$obj->product_desc.'</div>';
            echo '<div class="product-info">';
			echo 'Price '.$currency.$obj->price.' | ';
            echo 'Qty <input type="text" name="product_qty" value="1" size="3" />';
			echo '<button class="add_to_cart">Add To Cart</button>';
			echo '</div></div>';
            echo '<input type="hidden" name="product_code" value="'.$obj->product_code.'" />';
            echo '<input type="hidden" name="type" value="add" />';
			echo '<input type="hidden" name="return_url" value="'.$current_url.'" />';
            echo '</form>';
            echo '</div>';
        }
Link to comment
Share on other sites

I know of two approaches to solve this. At the end of cart_update.php, have:

* this statement: include /{full path to store code}/index.php;

* or this statement: header(location: /index.php );

 

The first saves a request by the browser, but the browser sees the incoming page as belonging to the last URL used.

The second allows for the code to retain important parts of the querystring, if needed, from the POSTed URL.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.