I have an OpenCart installation that is running two stores, one wholesale and one retail. The product catalog is shared, but the problem is that OpenCart doesn't natively support multiple pricing options. So I added a new field to the oc_product table, retail_price. The idea is that I would use the price field for wholesale pricing and the retail_price field for -- you guessed it -- retail pricing.
I have everything pretty much covered on the admin side, so my new field is showing in the product section and is being updated in the database.
Now the issue is getting the price to change on the front end for the retail store. Needless to say, product price is used in a ton of different scripts. So I figured the best/sneakiest method would be to change the price field when the database is queried and the price data is initially set. This is kind of where I got lost... I changed it in some places I thought were right but the price doesn't change on the front end. Sometimes OpenCart can be a mysterious fig.
Can anyone give me a clue as to where the best place(s) to change the price would be?
I assume that you've already created a different customer type for both wholesale and retail customers in the admin area.
That being the case, it's very simple to add this functionality to the model.
Open:
catalog/model/catalog/products.php
On or around line 22 you should see a line that looks like this:
$query->row['price'] = ($query->row['discount'] ?
$query->row['discount'] : $query->row['price']);
Determine the numerical value of your retail customer, let's assume it's 1 and wholesale customers is 2.
The variable $customer_group_id used below is previously set at the open of the getProduct() method.
Replace the previous line with the following:
if ($customer_group_id == 2):
$query->row['price'] = ($query->row['discount'] ?
$query->row['discount'] : $query->row['price']);
else:
$query->row['price'] = ($query->row['discount'] ?
$query->row['discount'] : $query->row['retail_price']);
endif;
Now if your customer is logged in and is not a wholesale customer, or is not logged in, they will see the retail price, if they are logged in as a wholesale customer they will see the wholesale price.
Related
Is it possible to add second price to each product and use that price if user in specific usergroup?
I was thinking doing that by adding another column to the product price table and then take advantage of the promotion function to somehow use that price instead of the usual discount you can set from admin.
Any pointers or ideas would be great, thank you.
Yes, it is possible to define price for product that is valid/shown only for users in specific usergroup.
To achieve this you need to use Quantity discounts tab on Editing product page.
Name of this tab implies as there must be some large amount of items bought (like volume discounts...), but quantity can also be just 1 item.
For this you first need to define usergroup (Customers->User groups).
Example is shown also on CS-Cart Knowledge base: Wholesale Prices
Best regards,
Bostjan
It is default CS-Cart feature. Please check the following article in the database:
http://kb.cs-cart.com/wholesale-prices
im creating a magento store for a B2B store.
The issue im facing is that i need to have a different price for a different customer group.
i have checked the built in group price feature in Magento but this is not what i need since it just shows a price for the specific groupo only when it is LOWER than the actual price and it shows it as a SPECIAL PRICE in the front end
What i need is to have a different price for each customer group without showing it as a SPECIAL PRICE is that possible ?
if yes how could i do that ? do i change some PHP code ?
Magento will always display the minimal price between actual price, special price, group price and the catalog price rule.
I trying to allow users to get the first product sample they add to their cart for free, but any samples they add after (including the one they already added) should be normal price. Right now I using setOriginalCustomPrice in a module, but the customer can change the quantity, and the price stays at zero instead of going up. Anyone know how to go about this?
You can achieve this by a simple calculation where you are using setOriginalCustomPrice.Currently I think you are setting price 0.Instead of doing this,use following logic to set custom price.
$customPrice=$qtyincart*$productPrice-$productPrice.
So if user add 1 qty then $customPrice will be 0 else will equal to sum of qty-1.
I hope this solve your purpose.
hey i'm implementing a custom discount system since magento discount system does not feet my requirements so i'm trying to apply a discount on an Mage_Sales_Model_Quote_Item I've read some and I've found the following function setOriginalCustomPrice the thing is that it applies on the item, and if the user changes the quantity he will get the discount on the item with the new quantity, so i'm trying to use a different method addOption on the item and only on the cart page show the calculations based on the quantity in the option value
$item->addOption(array('code'=>'promo','value' => serialize(['amount'=>10,'qty'=>1])));
and in the cart page
$promo = $item->getOptionByCode('promo');
echo '<div class="orig-price">'.$item->getOriginalPrice().'</div>';
echo '<div class="new-price">'.$item->getOriginalPrice() - ($promo['amount'] * $promo['qty']).'</div>';
the problem is that it does'nt actually apply the new price on the product,
so i want to customize Mage_Sales_Model_Quote->collectTotals() to show my discounts
and send it to the admin back-end when order is completed
how can i achieve that?
thanks in advance
I think there is a fundamental flaw in your approach. I'm not sure what you don't like in standard discounts, and what you can't achieve with catalog or shopping cart rules, but what you're trying to do definitely breaks these features (along with my heart).
However, if you're sure about what you're trying to do, then don't customize Mage_Sales_Model_Quote->collectTotals().
This function just... well, it collects all totals: subtotal, shipping, discount, etc. And it looks like you're changing only price output, but Magento itself doesn't know anything about it.
So if you want to let Magento know that you're changing the item price, you have to either add your own total, or change one of the existing totals. After that Magento will do everything else. Since after your changes Magento outputs already calculated price instead of original one, it may be strange for customer to see the original price in the cart and the additional discount total. So it looks like you will have to change subtotal total.
To do that you have to rewrite Mage_Sales_Model_Quote_Address_Total_Subtotal class in your extension and insert your calculation in _initItem() method. Around line 111 in the original file you will see the code:
$item->setPrice($finalPrice)
->setBaseOriginalPrice($finalPrice);
And this is where Magento sets price for the item, so you can insert your calculations and change $finalPrice before that. If you have virtual products, you will have to change collect() method too.
I have made a custom shopping cart in prestashop, I now need to increase the number of items bought in my shop manually. I guess this can be done by modifying the database. I tried changing the ps_product_sale table, but to no use. Can anyone suggest as to how to do it.
Thanks.
You can do it by making changes in the ps_order_detail table. In that table, PS stores all information for an ordered product like product id, name, product purchased quantities etc etc.
There is a column named product_quantity, change it and it will change the number of products bought.