RChilton Posted December 9, 2013 Share Posted December 9, 2013 I have a php shopping cart that I am editing that someone else developed. My php skills are still very beginner. Currently the customer must order $500 to place an order if their cart contains less they get a message - order must be $500. They want this to change so that any items that are in the categories of (accessories, scarves and jewelry) ONLY have a min order total of $150 but ALL other items in the other categories STILL have a min order total of $500. So in summary I need it to check if there are any items in accessories, scarves and jewelry - the total of those items OLY needs to be $150 if not a message needs to be displayed "boutique items have $150 min order." Then I need it to check all other items in the cart and those items ONLY need to total $500 or a message needs to be displayed "$500 min order required". There is a lot of other code mixed in with the current orderDetails page about coupons, etc which is throwing me off a little. I have attached a copy of orderDetails page so you could have all the code. I have also attached a screenshot of the cart page since it is unavailble for viewing unless you have a login. Thanks for the help. I need to get this fixed ASAP...I have gotten close a few times but just can not get it exact. orderDetails.php Quote Link to comment https://forums.phpfreaks.com/topic/284656-shopping-cart-min-order-problem/ Share on other sites More sharing options...
Ch0cu3r Posted December 9, 2013 Share Posted December 9, 2013 (edited) What you need to do is, during the checkout process go through each product stored in the basket and work out whether the product is in the accessories, scarves and jewelr categeories. Then work out the cost of the order and check to see if the passes the minimum order limits. Pseudo code would be $accessories_min_order = 150; $otheritems_min_order = 500; $accessories_order = 0; $otheritems_order = 0; foreach($item_in_basket as $item) { $sub_total = $item->price * $item->quantity; // work out item price if($item in accessories, scarves or jewelr catergory) // find out what category the item is in { $accessories_order += $sub_total; // running total for accessories } else { $otheritems_order += $sub_total; // running total for other items } } // check if accessories meets minimum order limit if($accessories_order > 0 && $accessories_order < $accessories_min_order) { accessories did not meet minimum order } // check if other items passes minimum order limit if($otheritems_order > 0 && $otheritems_order < $otheritems_min_order) { other items did not meet minimum order } process order Edited December 9, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/284656-shopping-cart-min-order-problem/#findComment-1461811 Share on other sites More sharing options...
RChilton Posted December 13, 2013 Author Share Posted December 13, 2013 I understand where you are going with this code. I jus can not seem to incorporate it into the existing code and get it to work. Quote Link to comment https://forums.phpfreaks.com/topic/284656-shopping-cart-min-order-problem/#findComment-1462263 Share on other sites More sharing options...
Ch0cu3r Posted December 13, 2013 Share Posted December 13, 2013 My code is not a copy and paste solution only a guide. I do not know how your shopping cart works so I cannot tell you where and what you need to change. Quote Link to comment https://forums.phpfreaks.com/topic/284656-shopping-cart-min-order-problem/#findComment-1462265 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.