Product Attribute/Variation Applies to Total - After Quantit

Posted by Community Admin on 05-Aug-2018 00:50

Product Attribute/Variation Applies to Total - After Quantity is Calculated

All Replies

Posted by Community Admin on 08-Feb-2013 00:00

Hello,

I've been unable to find a way to achieve this. Hoping someone may have some experience, know a plugin, or have a clever idea...

With product attributes/variations we can add the ability for a product to be altered and that alteration comes with a price increase.

So we have:

  • Product A = $100
  • Product A (gift wrapped) = $100 + $10

So above, if you ordered a quantity of 3, the first item would come to $300, and the second would come to $330.

But, what if "gift wrapping" only cost $10 no matter what the quantity was... And we actually need the second option above to total $310.

TotalItemPrice = (3 x 100) + 10

Is there a way to achieve this? 

Thanks,
Brandon

Posted by Community Admin on 09-Feb-2013 00:00

Also, for the record, I'm on Sitefinity 5.2.

Posted by Community Admin on 12-Feb-2013 00:00

We've heard from Telerik on this, and it sounds like the next release of Sitefinity may allow us to control pricing a bit more. However, timing on that is not going to be good for us.

We've not yet had any cleaver ideas on how to solve this in Sitefinity 5.2... If anyone has an idea, we'd really appreciate your thoughts.

Thanks,
Brandon

Posted by Community Admin on 12-Feb-2013 00:00

Hi Brandon,

One possible solution for you would be to make a hidden product for gift wrapping. Then using the techniques described here, add a giftwrap checkbox to the checkout and add the giftwrap product to the cart if it is checked.

Kind regards,
Randy Hodge
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 14-Feb-2013 00:00

Randy,

Thanks for your comments! It has taken me a while to get my head wrapped around this one... So you're recommending we create a generic "Gift Wrapping" product that costs $10, and then by adding a checkbox to the product itself we will be able to do two things:

  1. Recognize which products in the order have had a "Gift Wrapping" checkbox checked
  2. Trigger an add-to-cart function that simultaneously adds a second item to the cart, which is the "Gift Wrapping" product.

So, in the case that a user buys Products A, B (wrapped), C, and D (wrapped), the final order would look like this:

  • Product A [Qty 1] = $100 x 1
  • Product B (wrapped) [Qty 3] = $100 x 3
  • Product C [Qty 2] = $100 x 2
  • Product D (wrapped) [Qty 1] = $100 x 1
  • Gift Wrapping [Qty 2] = $10 x 2

So that totals $720. Two products were wrapped, thus $20, and the quantity of those two ignored (as I requested in my use-case scenario).

I think that could work. A tad odd for the user-experience, but I think it's ultimately understandable. The people invoicing the order will get the right amount, and thanks to the product checkbox, the people fullfilling the orders should recognize which items were requested for gift wrapping.

So the big question... How would we hook up an add-to-cart trigger that simultaneously adds a second product to the cart?

Thanks,
Brandon

Posted by Community Admin on 18-Feb-2013 00:00

Hello Brandon,

You can inherit from the AddToCart widget and override InitializeControls to subscribe to your own event for the button click. There you can check the product for gift wrapping and add the GiftWrap product to the cart or increment it's quantity if it's already there.

Regards,
Randy Hodge
the Telerik team

Posted by Community Admin on 19-Feb-2013 00:00

Randy,

I appreciate your help so far.

We're unable to implement your suggestion because we don't know how to hook into the correct processes, and we can't find any sample code of how to do it.

The "Add to Cart" widget seems to be unaware of the rest of the custom fields on the page at the time it is used -- it uses an AJAX call to add to cart. But we are unaware of a better hook in the processes of adding to the cart where we could check the products custom value settings.

We also couldn't find sample code for how to programmatically add a product to the shopping cart (or increment it's quantity).

Sample code seems sparse online, and the documentation doesn't get this detailed.

Any help is appreciated!

Brandon

Posted by Community Admin on 19-Feb-2013 00:00

I think we have it functional, in most respects now. I'll post more details after we know for sure, and finish testing.

However, we've found that this solution poses a "can of worms" of other things to consider... Such as, what if the user removes the original item that was set to be gift-wrapped once they make it to the checkout page? And it allows the new hidden "Gift Wrapping" product to be treated as any other, where it can be removed at checkout, but it is disconnected from the original item which is still "flagged" for gift-wrapping. A potential whole for getting the wrapping without paying for it...

Just some thoughts, if anyone else is trying to do this.

Posted by Community Admin on 20-Feb-2013 00:00

Randy, You mention creating a Hidden product. Can you explain how to do that. We've created the product but It's showing up in our site as a valid product. If I make it inactive then the shopping cart does a lot of unwanted stuff including not adding the product price to the total.

How can we make the product not visible to shoppers. 

Posted by Community Admin on 22-Feb-2013 00:00

Hello Brandon,

What you will need to try is leave the Gift Wrap product active and remove it from the ProductMasterList.

To do that, create a new class that inherits from ProductsMasterView and overrides the GetDataSource method.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.Modules.Ecommerce.Catalog.Web.UI.Views;
using Telerik.Sitefinity.Ecommerce.Catalog.Model;
using Telerik.Sitefinity.Model;
   
namespace SitefinityWebApp
    public class ProductsMasterViewCustom : ProductsMasterView
    
        protected override IList<Product> GetDataSource()
        
            IList<Product> prodList = base.GetDataSource();
             
            for (int x = prodList.Count - 1; x >= 0; x--)
            
                if (prodList[x].Title == "GiftWrap")
                
                    prodList.RemoveAt(x);
                    break;
                  
            
             
            return prodList;
        
    
Here we override GetDataSource. First, let the base class do the built-in implementation and get the product list. Then we look for the GiftWrap product and remove it from the list.
Save your class and build your web app.
Then register the new class as shown in this blog post.

I hope this helps you.

All the best,
Randy Hodge
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Jun-2013 00:00

Randy, Sorry so long getting back to you on this but we've been busy getting this site up and running. I just wanted to give you a big HIGH FIVE and thank you for your help. And let others know that your suggestions worked to resolve our issues.

We created a custom "AddToShoppingCart" widget where we add the "wrapping" product if the checkbox has been checked. And your "ProductsMasterViewCustom" code works great to keep the "wrapping" product from showing up in the store as regular product.

We do still have to watch for the disconnect between the "wrapping" product and the product to be wrapped where one or the other can be deleted once on the shopping cart. But we've been able to work with that until a better solution comes along.

This thread is closed