Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Hutch White 89 posts 112 karma points
    Sep 17, 2012 @ 17:10
    Hutch White
    0

    Shipping Method per Product

    Hey, hoping to get a little help here.  :)

    Looking to create something where the shipping is defined per product variant.  We want the customer admin to be able to change the price of the shipping method though and there will be two of them.

    Here's my thought (questions to follow):

    In example, I have 10 products, all with the same two variants relating to size (half order, full order).  I need shipping to be one base fee for all half order items and a different base fee for all full order items.  These base fees will need to be multiplied by the quantity of each type of product in the order.

    I'm thinking to create two shipping methods for my two types of products that will be used (half orders and full orders).  These would have the base price for each of these.  Then I would hook into the OrderLineAdded event, check the product variant name (can we do this?) and multiple the quantity by the base shipping price to calculate the proper fee.

    My questions are:

    Can I use two shipping methods to set base shipping prices for calculations?  

    Do I need a third shipping method that will always be used as the one assigned to the order object with the other two being for just definition purposes (setting base shipping price)?

    Can I grab the product variant name from the order line object?  How can I know which product was ordered so I know how to calculate the shipping cost?

  • Rune Grønkjær 1372 posts 3103 karma points
    Sep 17, 2012 @ 18:34
    Rune Grønkjær
    0

    Hi Hutch,

    The answer would be that your'e on the right path. Your solutions sounds good. Actually all you need is somewhere to store the two shipping base prices, so you can use them for your calculations. Using the Tea Commerce shipping methods will be a fast way of doing that, as Tea Commerce will cache them for you. The third shipping method would be set to zero in the fee, and will be the one that is selected on the order.

    In your OrderLineAdded event you just get the shippingmethods: ShippingMethod.GetShippingMethod( long id )

    And then calculate the shippingcost. And then add it to the order.

    /Rune

  • Rune Grønkjær 1372 posts 3103 karma points
    Sep 17, 2012 @ 18:38
    Rune Grønkjær
    0

    About the orderlines and getting info about which shipping type is used, you could just add that information to the orderline as a property.

    To display them on the order view you need to do like described in this recent thread:
    http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/34666-Viewing-OrderLineProperties-in-the-backend 

    /Rune 

  • Hutch White 89 posts 112 karma points
    Sep 17, 2012 @ 18:56
    Hutch White
    0

    Yes, but how can I determine the product variant selected?  I have two types of product variants on all products, Half order and Full Order.  I want to find if the product added is one of these (I don't mind selecting by if the name string has "half" or "full" in it).  Just need to know how to grab the product variant name in the orderline.  Can this be done?

  • Hutch White 89 posts 112 karma points
    Sep 17, 2012 @ 19:07
    Hutch White
    0

    Ah, so I could add an order property, but would this work for a product?  Wouldn't it be more of the product I need a property for and to check on that?

    The shipping is based on the actual product added, so I need to be able to determine which product was added from the extension.

  • Rune Grønkjær 1372 posts 3103 karma points
    Sep 18, 2012 @ 07:56
    Rune Grønkjær
    0

    Ok, it does sound like it should be at property on the product. Maybe a true/false property.

    To pass that information to the order line go to the Tea Commerce section > Settings > General settting.
    Then add the alias of your new product property to the Order line property aliases. After that the value will always be transferred from the product to the order line automatically.

    /Rune

  • Hutch White 89 posts 112 karma points
    Sep 18, 2012 @ 18:21
    Hutch White
    0

    Ok, got it and working very well.  :) 

    I have one problem; using the starter kit, step 3 of the checkout has the user pick their payment/shipping.  I've got this to only show the 'Default' emtpy shipping method that I'm using to be able to set a price to, but the price isn't updated here.  The shipping price shows fine on the next step, just not this one.  Thoughts?

  • Hutch White 89 posts 112 karma points
    Sep 18, 2012 @ 18:47
    Hutch White
    0

    It also appears that tax (VAT) isn't calculating properly.  Our tax rate is 6.35%.  It seems to only be calculating 6%.  Any reason it would truncate the decimals?  This happens on product pricing too, not just shipping.

  • Hutch White 89 posts 112 karma points
    Sep 18, 2012 @ 19:17
    Hutch White
    0

    Looks like I'll have to extend the OrderLineRemoved and OrderLineChanged to udpate shipping properly as well?  Is there a shortcut to this or will I need to do write methods for each of these to add/remove the shipping costs?

  • Hutch White 89 posts 112 karma points
    Sep 21, 2012 @ 21:54
    Hutch White
    0

    Alright, so this is working for adding one orderline.  It populates the amount properly for a quantity of that same orderline (if I order 2 of the same exact product it calculates correctly).  But if I add an entire new product to the order, it clears out the shipping and only totals for the last item.  Thoughts?

    Here's the main lines of the method I have hooked into OrderLineAdded:

    If (order.ShippingMethodId != intShipDefault)
    {
    order.ShippingMethodId = inShipDefault;
    }
    foreach (var property in orderLine.Properties)
    {
    if (property.Value.ToString().ToUpper() == "HALF")
    {
    shipFeeHalf = orderLine.Quantity * intShipHalfCost;
    }
    if (property.Value.ToString().ToUpper() == "FULL")
    {
    shipFeeFull = orderLine.Quantity * intShipFullCost;
    }
    }
    order.ShippingFeeWithoutVAT += shipFeeFull + shipFeeHalf;

  • Rune Grønkjær 1372 posts 3103 karma points
    Sep 24, 2012 @ 08:39
Please Sign in or register to post replies

Write your reply to:

Draft