Magento Shipping costs using category and weight - php

I'm working with magento 1.9.3 and need to change the shipping costs calculation based on table rate to use weight and category vs destination in the same table rate.
I have some products need to add extra cost based on category vs destination and the rest of products use the normal weight vs destination shipping cost calculation.
Before start coding i would like to have a different approach to find an easy and clean solution to this.
By now this is the idea
Add a new condition_name to the CSV named package_weight_category with category id as condition value
Modify the getRate method to find in the DDBB using the categories of the products in the cart and condition_name = 'package_weight_category'
If anything is found save the cost
Subtract the weight of the products of the categories found to the total weight
If weight >0 find the cost of the updated weight and add it to the cost
Return the calculated cost
My questions are
Is this solution functional?
It's possible pass the info of the categories and quantity of the products to the Mage_Shipping_Model_Rate_Request object?
Any better solution or different approach to solve this?
Thanks in advance just for reading

Related

Prestashop: Variable price based on product processing

I have one more complex questions, so I will split it. Since it is basically one topic I don't wanna to split it into two separate threads. I would be grateful either for any information about an existing module, or any idea how to do this by yourself.
Question #1
If I understand the product price calculation process in Prestashop I basically have two options:
Price defined on a product
Price defined on a product combination
What I need, though, is to provide customer with more advanced calculation. Let's say products can be assembled and equipped with multiple different tags. Therefore, I can't use product_attribute (Combination) as no matter if I assemble the product or not, it is always the same product with only one physical amount of products on stock. As if it was a Combination, and customer order the product assembled, the stock would only be decreased on for this Combination, but not for the other Combinations. Hope that makes sense.
Example:
Painting #348 + frame + additional service = $500
Painting #348 + frame = $375
Painting #348 = $345
It is even more complicated as these sort of "additional services" are only available to relevant products. Another products may offer customers different "additional services".
Question #2
For scenarios from Question #1, I need also to differentiate the price. So if a customer wants to buy 300 pieces of a painting with frame it is $10 cheaper per product. If the amount is over 500, it's $25 cheaper etc. I know I can do this for a regular product or a combination, but how would you do it if the price would be custom just like in Question #1.
Thanks a lot for any help!
I am not sure if i have understood your question completely or not but, as far as i understood here is your solution:
You may have a product:
XYZ Pizza
(with different toppings like chicken, red meat)
(also have sizes Small, Medium and Large)
Off course you will have different prices for different combination.
So what you can do is:
Create a product XYZ Pizza with price zero and quantity zero.
Add combinations to the product, so you just need to add actual price of that
combinations, no headache of increase decrease calculations for price.
It is super easy if you are using csv import.
And don't worry as long as you have a single combination with some price for that product the zero prices won't be shown on your website.
Hope it helps.

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.

Prestashop voucher system

The problem I am having is related to voucher codes.
By default, Prestashop will apply a discount of a particular product to the total of the entire cart. For example, if I have 3 products in my cart, all priced at £100, the total sum of the cart is £300.
If i have a voucher for a total value of £200 that is valid for only 1 of the 3 products in my cart, the behavior I want to achieve is that Prestashop will recognise that the voucher is valid for only one product, and rather than deducting the £200 voucher total from the cart total (essentially applying the remainder of voucher credit to the other two, non applicable items), it will deduct only the amount of all applicable items (in this case, £100), and some how create a new voucher for the remainder of the credit.
Hopefully this makes sense and many thanks in advance for any help offered.
Cheers
The only way to do it now is to create a new category (hidden), place the product in there (in addition to the current place), and assign the voucher to the new category.
Source
In PrestaShop, you can create a voucher for an individual category, but not yet for a specific product. At this point, product-specific vouchers would require changes to the code in several different places. As mentioned in Narek's source link, this is something the PrestaShop team is working on for a future release, but that functionality is not currently available in the default installation of PrestaShop.
Source: I am PrestaShop's Community Manager

How can i get products displayed with predefined quantities in magento?

I have some simple products setup that have various custom options, some of which are set to required. What I would like to do is get the products set up to where the customer can choose from predefined quantities for a certain price.
For example say the product is a widget, i want the customer to be able to choose from say 100 for $20, 200 for $35, 500 for $80 ..... and so on.
Tiered Pricing doesn't work since the prices are increasing.
I tried using a custom options which worked out price-wise BUT it did not update the total weight of the product which I need calculated in order to calculate shipping quotes.
I also tried using group products and setting the products within the group as the specific quantities and setting the calculated weights BUT it doesn't allow me to keep the custom options i have set as required.
So right now I'm just at a lost. Any Ideas how i can get this setup with the predefined quantities that also updates weight for shipping?
I'm using magento 1.6.0
Well after some more searching I found something that works....
http://www.magentocommerce.com/boards/viewthread/73036/

Grouped Product with Fixed Sub-item Quantities

I'm working on a Magento site that has a number of simple products. There's also a "holiday package" which combines several simple products into one, at a discounted price:
6 of Item A
2 of Item B
2 of Item C
2 of Item D
The "grouped" product type is pretty close to what I need - it allows each item to keep track of it's own stock, and when it comes time to ship and estimate packages, it tries to pack the containers using the weight/volume of each individual item. (This shipping aspect is very important, as we need to pack the boxes as efficiently as possible - using a simple product with an estimated size for all items may not work).
However, we do not want the customer to be able to choose the quantity of each item. The customer should instead be asked to choose how many holiday packages they would like.
Is a grouped product the best approach? Is there a better way to handle this?
In Magento 1.5.1, the best solution should be the bundle product. There, you can define a price, a quantity for each item in the backend. You can block the user to change the quantity for these items, not for the bundle product (you could too if you want but it's not your need here).
We do like that for some of our product. Check the screenshot to see an example of configuration

Categories