Copied to clipboard

Flag this post as spam?

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


  • Matt Taylor 873 posts 2086 karma points
    Jul 10, 2014 @ 17:40
    Matt Taylor
    0

    How to set the shipping price in v2?

    I'm implementing different shipping prices by weight based on this post.

    I'm using Umbraco v6 & Tea Commerce v2 so things are done a little differently.

    The bit I'm struggling with is the setting of the shipping price.

    In the original post it's done like this:

    order.ShippingFeeWithoutVAT = totalShippingPriceWithoutVAT;
    order.Save();

    In TC v2 you can't set the order.ShipmentInformation.TotalPrice.Value directly because it is read only.

    Instead I've created a new price object and assigned it.

    Price newShippingTotalPrice = new Price(shippingPriceWithoutVAT, order.VatRate, TeaCommerceHelper.GetCurrency(order.StoreId, order.CurrencyId));
    order.ShipmentInformation.TotalPrice = newShippingTotalPrice;
    order.Save();

    However the new shipping price does not get saved to the order.
    If I read the order back immediately using

    TeaCommerceHelper.GetCurrentOrder(order.StoreId);

    I can see it has not been saved.

    What am I doing wrong?

    Regards, Matt

  • Anders Burla 2560 posts 8256 karma points
    Jul 11, 2014 @ 08:26
    Anders Burla
    100

    Hi Matt

    You need to make a shipping calculator. Every time the order is saved we recalculate the shipping, order lines etc. That is why your price isn't "saved" - TC overwrites it when saving.

    See this:
    http://documentation.teacommerce.net/net-api/price-calculators/shipping-calculator/

    Kind regards
    Anders

  • Matt Taylor 873 posts 2086 karma points
    Jul 11, 2014 @ 09:22
    Matt Taylor
    0

    Ah, OK.

    I did see that documentation but resisted change. ;-)

    Regards, Matt

Please Sign in or register to post replies

Write your reply to:

Draft