barrieeksteen1 Posted May 8, 2014 Share Posted May 8, 2014 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>'; } Quote Link to comment https://forums.phpfreaks.com/topic/288332-php-shopping-cart-return-url-after-add-to-cart-not-working/ Share on other sites More sharing options...
bsmither Posted May 9, 2014 Share Posted May 9, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/288332-php-shopping-cart-return-url-after-add-to-cart-not-working/#findComment-1478883 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.