|
I solved this issue to my satisfaction, using a combination of existing backend Admin features, and a bit of a “hack” on cart.phtml. This method is free, but requires some familiarity with Magento files to modify in the future.
The end result is that:
1. The store displays and uses retail prices for all users not logged in, or logged in but not a member of the Wholesale customer group.
2. Once the Wholesale user logs in, the store displays both wholesale and retail prices (for reference), but uses the wholesale price.
3. The Wholesale user can view their cart, but, unless their order is above a specified amount (e.g. $1000), cannot checkout because the checkout buttons will not render, and an an error message will appear on the page.
Steps:
1. ASSIGN USER TO WHOLESALE CUSTOMER GROUP
a) Admin->Customers->Manage Customers
b) Pick a customer and select “Assign to Customer Group” in the Actions dropdown, then choose the Wholesale customer group.
2. SET PRICING FOR WHOLESALE CUSTOMER GROUP
a) Admin->Catalog->Manage Products->(any product)->Prices->Tier Prices
b) Create a tier price with the settings: Customer Group: Wholesale, Qty: 1 and above, Price: [your wholesale price]
(The price in the “Price” field at the top of the page will be used for all non-Wholesale customers)
At this point, if the Wholesale customer logs into their account, and browses the catalog, they will see the both the default and the Wholesale price, but the wholesale price will be used for all intents and purposes.
3. SET MINIMUM ORDER AMOUNT FOR WHOLESALE CUSTOMER GROUP
This is the tricky bit.
Open your app/design/frontend/default/[your theme]/template/checkout/cart.phtml
1. Add the following code to the beginning of the file, right above <div class="cart">
<?php
$logged_in = Mage::getSingleton( 'customer/session' )->isLoggedIn();
if ($logged_in) {
$group = Mage::getSingleton('customer/session')->getCustomerGroupId();
$grand_total = Mage::helper('checkout')->getQuote()->getGrandTotal();
$minimum_order = 1000;
}
?>
This code checks if the user is logged in, and if so, finds out which Customer Group they are in, their cart total, and creates a variable to store what you want the minimum order amount to be.
2. Find the following code on your page (it will appear twice):
<ul class="checkout-types">
<?php foreach ($this->getMethods('top_methods') as $method): ?>
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
<li><?php echo $methodHtml; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
This is the code that renders the checkout buttons.
Replace the first instance of that code with:
<?php if (($group == 2 && $grand_total > $minimum_order) || $group != 2): ?>
<ul class="checkout-types">
<?php foreach ($this->getMethods('top_methods') as $method): ?>
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
<li><?php echo $methodHtml; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php if ($group == 2 && $grand_total < $minimum_order): ?>
<span style="color: red">Note: The minimum order amount for Wholesale customers is $1000. Please add more items to your cart.</span><br /><br />
<?php endif; ?>
and the second instance with:
<?php if (($group == 2 && $grand_total > $minimum_order) || $group != 2): ?>
<ul class="checkout-types">
<?php foreach ($this->getMethods('top_methods') as $method): ?>
<?php if ($methodHtml = $this->getMethodHtml($method)): ?>
<li><?php echo $methodHtml; ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
What this does is prevent the checkout buttons from rendering if the customer is a wholesale customer ($group == 2) and their cart total is less than the minimum you want ($grand_total > $minimum_order). An error message will be displayed in red at the top of the cart page.
The buttons will render for everyone else, with no error message.
NOTES:
1. When the Wholesale price is set as a tier price, some verbiage will appear around it on the front end: ‘as low as’, etc. These can be modified by using template path hints to find and modify the relevant files.
2. The customer group associated with a tier price may be lost on product export/import. The fix for this is dealt with on other threads.
3. You can use this method to create multiple Customer Groups all with different pricing and minimum order amounts.
|