Magento tiered pricing change format - php

At the moment, my webstore uses several different customer groups to provide discounts, such as trade discounts. The functionality works fine, but i want to change the way the prices are displayed on the front end. Right now, the prices show like this:
£700.00
Buy 1 for £450.00 each and save 36%
For instance. So the customer is logged in, they can see the Retail price and then their price is the £450. I wish for it to say
List Price: £700.00
Your Price: £450.00 (save 36%).
Is this possible?
The other issue is that when a customer is not logged in, i just want them to see the list price, and not the discounts etc.
How would i do this?

Yes its possible. You have to play with the file price.phtml and/or view.phtml.
To get original price, use getPrice() method on your product object. To get discounted (final) price, use getFInalPrice()
Product object is usually $_product, so
$_product->getPrice();
$_product->getFinalPrice();
Now you may display however you wish.

Related

Ecommerce database design, save product information without affecting historical data

What would be the best, if not, the practical way to design an e-commerce database wherein the product information of the product purchased by a customer should not update when the product information was updated?
To give a better understanding, here's a scenario:
Merchant created "Product A" where it is priced at $50.
Customer saw Product A and purchased it.
Customer visited the transaction history and viewed his recent purchase: Product A priced at $50
Month's after, Merchant updated the price of Product A to $80.
Customer viewed again his transaction history. His transaction with Product A should retain at $50 and not the updated price of $80 because it was the price he paid that time.
One solution I am looking into is to save the whole product information in a table as a PHP serialized data in "purchases.product_information".
Is it even a good idea to store PHP serialized data in a column? How's performance if a user wanted to search for a text in the product information like price, item name, etc.?
Any other workaround for this?
Thank you
It is a case of slowly changing dimensions (https://en.wikipedia.org/wiki/Slowly_changing_dimension)
A simple solution will be to have a separate table purchase_items and have all the columns that may change over time against each item (Example:price, discount etc) and purchase and purchase_items table will have one_to_many relationship
Although, there are more complex situations where the price of the product changes on the fly based on the time at which an order is made in a day etc. In these cases, the price may not be stored against the product itself
This answer is addresses exactly the issue and you might find this helpful
https://dba.stackexchange.com/questions/57992/ecommerce-orders-table-save-prices-or-use-an-audit-history-table

WooCommerce change tax per product programmatically

The problem is: If we sell a ticket to our customer, we pay the tax not where the customer lives and not where the company of the shop is located. We pay the tax, where the event is held.
We can use a workaround where we can define a tax class for each country, with the rate. But this is very ugly.
I would like to develope something where I can set the country for the events and WooCommerce will use this country as a tax base, just for this product.
My problem is, that I don't know which filter I should apply. I found some, but the filter don't give the product object or the product id as parameter.
For example: https://docs.woocommerce.com/wc-apidocs/source-class-WC_Checkout.html#468
Does someone have an idea?
thanks for getting back to me. That's the "hack" I implemented but it solved for me
I used the filter woocommerce_price_ex_tax_amount (there is also, woocommerce_price_inc_tax_amount) for inclusive tax calculation.
It receives $tax_amount (already calculated), $key, $rate, $price.
You can setup a fictitious tax rate for every ticket and modify it programatically. As you'll receive the price as well, you can recalculate the rate base on it and return it.
Hope it helps,

Magento - Display higher price for product

It is evident that Magento always displays the lowest price of the original price, special price, etc.
I have a condition where I have to display the customer specific price that comes from an ERP system. Let's call it special price. If that special price is higher than the product's price, Magento obviously chooses the least one.
The question, is there any way to override this in a smooth way? Because regardless of the products' price, the requirement is to display the customer specific price from the ERP system on Magento.If there is no customer specific price available, it is OK to fallback to the products' price.
Override
Mage_Catalog_Model_Product_Type_Price
Check Customer specific price against Products price and Do the logic

magento customize quote collectTotals to show the updated totals

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.

Sylius - How to define product with options that have impact on price?

In Sylius I can create variant of of a product, for instance 3 sizes of a t-shit, each size have different price. This is a nice solution if I have a product with one thing that has an impact on a price.
What about situation, where I have a Tshirt which have many options that have an impact on price, like:
Size
Material
Color
and few more
I cannot create product with variants, of each configuration. It should be for example in a way, that this particular option has an impact on price by adding to it some amount of money or %. This is like Adjustment, I think. But how to use it for products?
----MORE DETAILS--------
I need to define a product with some options that have impact on price, like Adjustments. Then when User adds product to cart, he/she chooses some options. Each of these options changes the product price. So base product has price $20. But when user adds it to cart, change 3 parameters, then the price should be $35. And this product with $35 price should be added to a cart, and then to an order.
You can consider listening to product or variant post create event, then in your listener check what options are set and adjust price according to options.
Maybe You can use custom PriceCalculator which must use CalculatorInterface.
In this class could be implemented all custom logic which depend of product.

Categories