Jump to content

Recommended Posts

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

post-166821-0-34318200-1386605792_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/284656-shopping-cart-min-order-problem/
Share on other sites

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 by Ch0cu3r
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.