Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Need to add additional fees to products based on categories
 
srmobile
Sr. Member
 
Total Posts:  276
Joined:  2011-10-25
 

I have different categories that have different additional fees that vary depending on the category the reside.
For example we have a category “Screens”, when you purchase a screen for 100$, there needs to be an additional fee for 5$ for environment handling.  This fee would need to appear as a separate item in the cart.

What I thought I could do is create a product for each fee and link them together based on category.

How would I best achieve this?

Thanks!

SR

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ryan Sun _Kuafu
Guru
 
Total Posts:  317
Joined:  2008-11-14
FL
 

create a custom attribute additional_fee to category (mostppl do it by custom upgrade script, you can find many post about it)
rewrite price model and have $product->getCategoryCollection()->getFirstItem()->getAdditionalFee() add to getFinalPrice()

this is not the best solution as a product might belong to many categories. you can create different product types and define different price class to serve your purpose

 
Magento Community Magento Community
Magento Community
Magento Community
 
srmobile
Sr. Member
 
Total Posts:  276
Joined:  2011-10-25
 
Ryan Sun _Kuafu - 05 March 2013 04:44 AM

create a custom attribute additional_fee to category (mostppl do it by custom upgrade script, you can find many post about it)
rewrite price model and have $product->getCategoryCollection()->getFirstItem()->getAdditionalFee() add to getFinalPrice()

this is not the best solution as a product might belong to many categories. you can create different product types and define different price class to serve your purpose

Hi Ryan,

So would this be a good template to use?

http://magenting.wordpress.com/2011/11/10/adding-a-category-attribute-in-magento/

And just to be clear, you were referring to the price.php located in Mage/Catalog/Model/Product/Type/ correct?

(I had written this long reply but entered the captcha wrong and lost everything..... this is the shortened version)

Thanks!

SR

 
Magento Community Magento Community
Magento Community
Magento Community
 
jeffcustom
Member
 
Avatar
Total Posts:  67
Joined:  2012-11-29
Boulder, CO
 

If you want it to be a different item added to the cart, you are better off taking 1 of 2 routes.

Route 1:
Pass in the “fee” item as a related product in the catalog/product/view.phtml template file (<input type="hidden" ... )

Route 2:
Define an observer to hook into the add to cart, update quantity, or remove from cart events. You can then look through a given product’s category ids and use Mage::getSingleton("checkout/cart")->addProduct() to add it into the quote.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ryan Sun _Kuafu
Guru
 
Total Posts:  317
Joined:  2008-11-14
FL
 
srmobile - 05 March 2013 06:54 AM


Hi Ryan,

So would this be a good template to use?

http://magenting.wordpress.com/2011/11/10/adding-a-category-attribute-in-magento/


And just to be clear, you were referring to the price.php located in Mage/Catalog/Model/Product/Type/ correct?

(I had written this long reply but entered the captcha wrong and lost everything..... this is the shortened version)

Thanks!

SR

1, yes
2, depends on your product type, but yes Mage/Catalog/Model/Product/Type/Price.php is the price model for most types

 
Magento Community Magento Community
Magento Community
Magento Community
 
srmobile
Sr. Member
 
Total Posts:  276
Joined:  2011-10-25
 
jeffcustom - 05 March 2013 08:16 AM

Route 2:
Define an observer to hook into the add to cart, update quantity, or remove from cart events. You can then look through a given product’s category ids and use Mage::getSingleton("checkout/cart")->addProduct() to add it into the quote.

Do you have an example of what this kind of code would look like?

Thanks!

SR

 
Magento Community Magento Community
Magento Community
Magento Community
 
srmobile
Sr. Member
 
Total Posts:  276
Joined:  2011-10-25
 
Ryan Sun _Kuafu - 05 March 2013 08:43 AM


1, yes
2, depends on your product type, but yes Mage/Catalog/Model/Product/Type/Price.php is the price model for most types

Awsome, thanks Ryan!!

So far I’ve gotten the attribute to appear on the categories and I’m going to try and modify the price.php and see what kind of results I get.  smile

SR

EDIT: Not having much luck. I’ve modified the price.php in the section that appears to be for calculating the final price but when I make any changes, only 1 item appears in my test store and when I click on it, I get some weird results.

 
Magento Community Magento Community
Magento Community
Magento Community
 
srmobile
Sr. Member
 
Total Posts:  276
Joined:  2011-10-25
 

In case someone falls on this thread while searching the inter webs: I ended up purchasing a module that does exactly what I was trying to accomplish. I can muddle my way through some code but far from a php / MySQL programmer.

The module is: http://www.magentocommerce.com/magento-connect/j2t-auto-add-va.html

I created a product called “Environment Fee” and applied it to specific categories. The module is extremely flexible in that you can have different rules for different categories.

SR

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagikTejas
Sr. Member
 
Avatar
Total Posts:  150
Joined:  2009-07-29
 

Hello,

Magento Extra Fee extension allow you to apply the product,category,shipping & order type fees. With which you can apply the same category fee to all the products in particular category or apply separate fees to individual products. Also have ability to apply the fee on entire order or add extra shipping charge.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageBright
Sr. Member
 
Avatar
Total Posts:  100
Joined:  2011-11-21
 

Hi
Please Check May be someone help this extension

http://www.magentocommerce.com/magento-connect/surcharge-extension.html

http://www.magebright.com/surcharge-extension.html

Thank you

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top