Copied to clipboard

Flag this post as spam?

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


  • Bex 444 posts 555 karma points
    Oct 24, 2011 @ 12:31
    Bex
    0

    Different shipping cost per product and per country

    Hi

    Could you tell me is there an easy way to implement different shipping costs and methods per product?

    Some items in my clients shop will need couriering due to size and some will be sent by post.
    The prices for these will also vary depending on size and where in the world they are being sent to.

    I am thinking  a number of shipping methods will be created and then each product will have a drop down of "shipping method" and then the front end will either automatically work out their country or they will select it to decide on the cost.

    Is this a standard teacommerce way of doing things or would I have to create something custom?

     

    Bex

     

     

     

  • Anders Burla 2560 posts 8256 karma points
    Oct 24, 2011 @ 12:55
    Anders Burla
    0

    Hi Bex

    As a start - this is not a standard thing in Tea Commerce - you will have to do some custom programming - but its definitely possible using the Tea Commerce .NET API. You could make a custom datatype to have the shipping method selection for the different products. Then you would have to make some programming logic for the shipping method selection in your .NET code - if will have to decide what should happen if a customer has selected a product with two different shipping methods, and also based on the customers country etc.

    But have a look at the Tea Commerce documentation and feel free to add to this forum post any other questions regarding your advanced shipping setup.
    http://www.teacommerce.dk/en/documentation.aspx

    Kind regards
    Anders

  • Bex 444 posts 555 karma points
    Oct 24, 2011 @ 13:00
    Bex
    0

    Thanks again Anders for your prompt reply.

    Unfortunately I thought as much :( 

    I will sort something custom then but I will leave this thread open as I'm sure I will have some questions!

    Bex

  • Anders Burla 2560 posts 8256 karma points
    Oct 24, 2011 @ 13:05
    Anders Burla
    0

    Your welcome - and of course keep it open for more questions for the custom shipping setup.

  • Bex 444 posts 555 karma points
    Oct 24, 2011 @ 16:18
    Bex
    0

    Hi 

    I have a few questions on how I am intending doing my custom shipping..

    1. In my datatype for the product document I need a list of shipping methods, I have tried using "TeaCommerce.Library.GetShippingMethods()" but it only seems to bring back an item called "Shipping methods", so how do I get a list of the shipping methods?
       
    2. I have hooked into the "OrderlineAdded" Event and this is where I intend in applying my shipping method. Would this be the correct place?
       
    3. I have noticed that you have to apply a shipping method to an order rather than an item which is logical,but because of the different items that can be bought this means I am having difficulty working out the shipping method. For example they may be ordering 2 large items that cost £50 each to courier.
      Is there a way of combining shipping methods or would you have to create a whole new one from an amalgamation of the items in the basket and add a name to it or something? Or will I need to limit the user to ordering one thing at once?
       
    Thanks
    Bex
  • Anders Burla 2560 posts 8256 karma points
    Oct 24, 2011 @ 16:47
    Anders Burla
    0

    Hi Bex

    Just use TeaCommerce.Data.ShippingMethod.GetShippingMethods() - this gives you the .NET objects - the other one gives you an xsltnavigator :)

    The OrderlineAdded event would be a good place if it depends on which orderlines the customer has added to the basket - but cant answer 100% as I would have to know the entire setup and how the webshop is setup, how you manage the shipping methods etc. so its a bit hard to answer that :)

    You can only have 1 shipping method pr order - BUT you can change the price of it - so you could have a shipping method named "test". You set that as the default shipping method for your country. Now when the customer add products you change the price of the shipping method in the .NET code. Would that do the trick?

  • Bex 444 posts 555 karma points
    Oct 24, 2011 @ 16:55
    Bex
    0

    Anders,

    Thanks! That helps.

    I think just combining the cost should do the trick.., then I could just add a "shipping cost" to the product! I think that will work!

    You wait they'll be asking for discounted shipping costs next.. should probably look into that too just incase! :)

  • Bex 444 posts 555 karma points
    Oct 24, 2011 @ 18:14
    Bex
    0

    Hopefully my final question..

    How do I get the cost of the shipping method for a country using the .net api?
    I can do this..  

    Country c = new Country(....)
    c.ShippingMethod.GetFee() 

    but I think this just gets the default shipping method fee?
    I kind of need it the other way round, something like this..

    ShippingMethod sm =ShippingMethod.GetShippingMethod()
    sm. get fee for the country 

    I need to work out the fee in code where I will have the country Id and the shipping method Id but will not yet have put it in the database.

    Thanks

    Bex

  • Anders Burla 2560 posts 8256 karma points
    Oct 24, 2011 @ 18:53
    Anders Burla
    0

    You have the ShippingMethod.GetFee( Order order ) right? That method returns the fee based on a calculation based on the orders current country and currency and returns the right fee.

    If you need to do the calculation your self you will have to find the correct shipping method. Select the correct shippingCountry from its Shipping Countries property. Use that shippingCountry to select the right shippingCurrency using the ShippingCurrencies property of the shipping country. When you have that shipping currency you can call the method GetFeeWithoutVAT( ... ) 

    As you can see this gives you some more work - so hope you can use that standard way of getting the shipping costs :)

  • Bex 444 posts 555 karma points
    Oct 25, 2011 @ 09:58
    Bex
    0

    Yeek.. well seems like that is the way I need to do it.
    I had integrated TeaCommerce into the site already and was ready to purchase a licence and go live when the client said.. "by the way you do realise that shipiing costs will be different, oh yeah and you need to take into account different countries....!!"

    So it's a bit of a bolt on, and it's going to go off the country dropdown on the delivery address.

    So I am using this:

     ShippingMethod sm =ShippingMethod.GetShippingMethod(...)
     var fee;       
    foreach(ShippingCountry c in sm.ShippingCountries ) { if (c.CountryId ==...) { foreach (ShippingCurrency sc in c.ShippingCurrencies ) { if( sc.CurrencyId ==...) {  fee= sc.GetFeeWithoutVAT(..countryId..,0, order.totalprice)
    }
    }
    }
    }

     

     Can you let me kniw if this is correct just incase!

    Bex

  • Anders Burla 2560 posts 8256 karma points
    Oct 25, 2011 @ 11:17
    Anders Burla
    0

    Hi Bex

    Isnt this the best and a possible way to do it?

    ShippingMethod shippingMethod = ShippingMethod.GetShippingMethod( 1 );
    decimal fee = shippingMethod.GetFee( order );

    This does give you the right fee for the shipping method based on the current country of the order and the current currency of the order. If not could you try in a more detailed way describe your senario and what you want to do in the more complex calculation?

    Kind regards
    Anders

  • Bex 444 posts 555 karma points
    Oct 25, 2011 @ 11:26
    Bex
    0

    Hi Anders

    Having just been looking at it I have determined this too..

    I forgot that you could assign any currency to a country (as it all has to be in GBP) and that the dropdown for country could update the sites's country instead of just passing in the country id and having to work it out.

    The only difference between the regular way of setting a shipping price is that I need to calculate the price for each individual item from the shipping method applied to it and then add them together. Initially I didn't have a country selection on the site at all, so I am adding it. That's why I was getting confused I think.

     

  • Anders Burla 2560 posts 8256 karma points
    Oct 25, 2011 @ 12:17
    Anders Burla
    0

    Cool - sounds like the right way to do it. Yes you just calculate the total price for each orderline and set the order.ShippingFee or order.ShippingFeeWithoutVAT to have the new total shipping fee.

  • Bex 444 posts 555 karma points
    Oct 25, 2011 @ 14:52
    Bex
    0

    Hi!

    Almost there now, but one silly little thing can't work out, how do I get the total price of an order without shipping?
    I'm using this for total price

    <xsl:value-of select="$order/@totalPriceFormatted"/> 

    Is there something similar for without shipping? Actually also the same for just shipping?

    I am using this on my cart page and finding if they go to the checkout then back to the cart the whole price is showing and it doesn't make sense!

    Thanks

    Bex

     

  • Anders Burla 2560 posts 8256 karma points
    Oct 25, 2011 @ 15:15
    Anders Burla
    0

    Hi Bex

    You have the $order/@totalPriceWithoutFeesFormatted (without both shipping and payment fee) - and then $order/shipping/@feeFormatted

  • Bex 444 posts 555 karma points
    Oct 25, 2011 @ 17:55
    Bex
    0

    Ok, finally got it all sorted!

    Thanks for all your help Anders! You have been fantastic!

  • Anders Burla 2560 posts 8256 karma points
    Oct 25, 2011 @ 17:57
    Anders Burla
    0

    Great to hear that your sorted it! Looking forward to see the webshop online.

    Have a great day

  • Hutch White 89 posts 112 karma points
    Sep 13, 2012 @ 00:02
    Hutch White
    0

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

    I'm looking to do the exact same thing on another project.  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 fee for all half order items and a different base fee for all full order items.

    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?

  • Rune Grønkjær 1371 posts 3102 karma points
    Sep 17, 2012 @ 08:53
    Rune Grønkjær
    0

    Hi Hutch,

    These questions almost deserves it's own forum thread, as they could be very relavant for others as well.

    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

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

    Ok, I'll start a new thread.  Still will need to know how I can get the orderline detail to know which product variant was picked so I know which shipping value to use.

Please Sign in or register to post replies

Write your reply to:

Draft