Copied to clipboard

Flag this post as spam?

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


  • Michael Sims 119 posts 387 karma points
    May 01, 2013 @ 14:49
    Michael Sims
    0

    Shipping per product

    I am using Tea Commerce 2 and am wanting to add a shipping cost per product and country combination.

    Can anyone tell me how I go about doing this?

  • Rune Grønkjær 1371 posts 3102 karma points
    May 01, 2013 @ 15:09
    Rune Grønkjær
    0

    Sounds very interesting Michael. I think I would go with creating the shipping costs as seperate products.

    You can create one Shipping cost product node (Maybe give it its own doc type).
    Then use the Tea Commerce .NET API to hook into the whenever a product is added.
    You can then add the shipping cost product to the order using the unique orderline property on the order line. Unique order lines will let you add the same product to the cart multiple times (As different order lines).
    The order line custom properties can be used to link the product order line and the shipping cost order line to each other.
    After that it's all about how you visually display your order to the customer.

    Heres an example of how to hook into our events in Umbraco 6+:

    using System.Collections.Generic;
    using TeaCommerce.Api.Models;
    using ApiNotifications = TeaCommerce.Api.Notifications;
    using Umbraco.Core;
    
    namespace Muubs.Website.TeaCommerceExtension {
      public class Notifications : IApplicationEventHandler {
    
        public void OnApplicationInitialized( UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext ) {
        }
    
        public void OnApplicationStarted( UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext ) {
          ApiNotifications.NotificationCenter.Order.OrderLinesAdded += Order_OrderLinesAdded;
        }
    
        public void OnApplicationStarting( UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext ) {
        }
    
        void Order_OrderLinesAdded( Order order, IEnumerable<OrderLine> orderLines ) {
          //Do magic stuff here
        }
    
      }
    }

    /Rune

  • Michael Sims 119 posts 387 karma points
    May 01, 2013 @ 15:35
    Michael Sims
    0

    Is there a way to override the shipping cost calculation?

  • Rune Grønkjær 1371 posts 3102 karma points
    May 01, 2013 @ 15:54
    Rune Grønkjær
    0

    Yes. Absolutely. There's a full order calculator API which you can overwrite whereever you want (e.g. the shippingprice)

    You can then do whatever calculations you need to get the correct shipping price. Not for every single product, but for the entire order though!

    I have not done this yet, so I will have Anders Burla write you some example code here!

    /Rune

  • Michael Sims 119 posts 387 karma points
    May 01, 2013 @ 17:00
    Michael Sims
    0

    OK. I want it to calculate and return a total shipping cost for all the products by first determining the current currency and chosen shipping method and then looking for a field in the product which is unique per currency and shipping combination.

  • Michael Sims 119 posts 387 karma points
    May 01, 2013 @ 17:48
    Michael Sims
    0

    Can I get a list of API calls for V2? Without it the whole thing feels fairly impossible to use.

    I need to get the default shipping method for the shipping country. Any ideas?

  • Anders Burla 2560 posts 8256 karma points
    May 02, 2013 @ 08:34
    Anders Burla
    0

    Hi Michael

    Custom shipping provider:

    [SuppressDependencyAttribute( "TeaCommerce.Api.PriceCalculators.IShippingCalculator", "TeaCommerce.Api" )]
    public class OwnCustomShippingCalculator : ShippingCalculator {

    public OwnCustomShippingCalculator( IVatGroupService vatGroupService, ICurrencyService currencyService )
    : base( vatGroupService, currencyService ) {
    }

    protected override decimal CalculatePrice( ShippingMethod shippingMethod, Currency currency, long countryId, long? countryRegionId ) {
    //Price while no order is present for the customer
    return 1000000M;
    }

    protected override decimal CalculatePrice( ShippingMethod shippingMethod, Currency currency, Order order ) {
    //Price when having an order
    return 1000M;
    }

     

    About the country and default shipping method. You load models using services. So Country will be CountryService.Instance.Get(storeId, countryId). Then use the DefaultShippingMethodId property. Then use ShippingMethodService.Instance.Get(storeId, shippingMethodId).

    Kind regards
    Anders

  • Michael Sims 119 posts 387 karma points
    May 02, 2013 @ 11:28
    Michael Sims
    0

    Thanks for the example. I've tried adding it but I am getting the following error:

    System.TypeLoadException: Could not load type 'TeaCommerce.Api.Dependency.SuppressDependencyAttribute' from assembly 'TeaCommerce.Api, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.
  • Rune Grønkjær 1371 posts 3102 karma points
    May 02, 2013 @ 11:30
    Rune Grønkjær
    0

    Have you updated to Tea Commerce 2.1?

    /Rune

  • Michael Sims 119 posts 387 karma points
    May 02, 2013 @ 11:37
    Michael Sims
    0

    No. Do I need to update?

  • Anders Burla 2560 posts 8256 karma points
    May 02, 2013 @ 11:45
    Anders Burla
    0

    Yes you need to do that. The suppress dependency is added in 2.1

  • Michael Sims 119 posts 387 karma points
    May 02, 2013 @ 11:54
    Michael Sims
    0

    Ok. I've upgraded but now none of my macros work.

    Even this simple one is returning an error:

     

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @using TeaCommerce.Api.Common

    @using TeaCommerce.Umbraco.Web

    @using TeaCommerce.Api.Models

    @{

    //Store id

    long storeId = long.Parse( Model._Store );

    var currentCurrencyId = TC.GetCurrentCurrency(storeId).Id;

    }

    <select id="currency">

    @foreach (var currency in TC.GetCurrencies(storeId))

    {

    var selected = currentCurrencyId == currency.Id ? " selected=\"selected\" " : "";

    <option @Html.Raw(selected) value="@currency.Id">@currency.Name</option>

    }

    </select>

  • Michael Sims 119 posts 387 karma points
    May 02, 2013 @ 12:03
    Michael Sims
    0

    Never mind. I touched the config and everything magically started working again.

  • Michael Sims 119 posts 387 karma points
    May 02, 2013 @ 13:41
    Michael Sims
    0

    Okay, so I've upgraded to 2.1 and I have added my custom shipping dll to the bin folder. The shipping is now displaying the correct amount but I now get the error message "" when trying to checkout with PayPal.

    "You have entered an invalid quantity value. A quantity value must be an integer greater than or equal to one."

    Looking at the html generated I can only assume that this is a bug because my basket has 2 items and the html shows items for tax and shipping which both don't have a quantity. In addition since upgrading the WorldPay option now fails when trying to generate the form.

    <input id="business" type="hidden" value="ABC123" name="business">
    <input id="lc" type="hidden" value="UK" name="lc">
    <input id="return" type="hidden" value="http://blah/base/TC/PaymentContinue/1/PayPal/3f071d75-8151-4937-9d26-be7434d06113.aspx" name="return">
    <input id="cancel_return" type="hidden" value="http://blah/base/TC/PaymentCancel/1/PayPal/3f071d75-8151-4937-9d26-be7434d06113.aspx" name="cancel_return">
    <input id="paymentaction" type="hidden" value="authorization" name="paymentaction">
    <input id="cmd" type="hidden" value="_cart" name="cmd">
    <input id="upload" type="hidden" value="1" name="upload">
    <input id="currency_code" type="hidden" value="GBP" name="currency_code">
    <input id="invoice" type="hidden" value="CART-134" name="invoice">
    <input id="no_shipping" type="hidden" value="1" name="no_shipping">
    <input id="rm" type="hidden" value="2" name="rm">
    <input id="notify_url" type="hidden" value="http://blah/base/TC/PaymentCallback/1/PayPal/3f071d75-8151-4937-9d26-be7434d06113.aspx" name="notify_url">
    <input id="item_name_1" type="hidden" value="blah RMA " name="item_name_1">
    <input id="item_number_1" type="hidden" value="1091" name="item_number_1">
    <input id="amount_1" type="hidden" value="185.00" name="amount_1">
    <input id="tax_1" type="hidden" value="37.00" name="tax_1">
    <input id="quantity_1" type="hidden" value="1.0000" name="quantity_1">
    <input id="item_name_2" type="hidden" value="blah PV" name="item_name_2">
    <input id="item_number_2" type="hidden" value="1126" name="item_number_2">
    <input id="amount_2" type="hidden" value="387.00" name="amount_2">
    <input id="tax_2" type="hidden" value="77.40" name="tax_2">
    <input id="quantity_2" type="hidden" value="1.0000" name="quantity_2">
    <input id="item_name_3" type="hidden" value="Shipping (UK)" name="item_name_3">
    <input id="amount_3" type="hidden" value="18.00" name="amount_3">
    <input id="tax_3" type="hidden" value="3.60" name="tax_3">
    <input id="item_name_4" type="hidden" value="PayPal" name="item_name_4">
    <input id="amount_4" type="hidden" value="0.00" name="amount_4">
    <input id="tax_4" type="hidden" value="0.00" name="tax_4">
    <input id="next" class="btn btn-brown button small" type="submit" value="Confirmation">
  • Anders Burla 2560 posts 8256 karma points
    May 03, 2013 @ 09:58
    Anders Burla
    0

    Hi Michael

    Reading the PayPal documentation the quantity isn't required so that should work.
    http://www.paypalobjects.com/en_US/ebook/PP_WebsitePaymentsStandard_IntegrationGuide/Appx_websitestandard_htmlvariables.html

    Could you try and change the format of the quantity of from 1.0000 to just 1 - just to see if its a format problem.

    About WorldPay - nothing changed in the provider from 2.0 to 2.1

    Kind regards
    Anders

  • Michael Sims 119 posts 387 karma points
    May 03, 2013 @ 12:09
    Michael Sims
    0

    Hi Anders,

    Your guess was correct this is a format problem I changed as you suggested and this resolved the issue. Can you add this to the patch you are doing for the basket? How is that coming along? My client is rather desperate to launch.

  • Michael Sims 119 posts 387 karma points
    May 03, 2013 @ 12:24
    Michael Sims
    0

    Okay. So I've finally got to the bottom of the issue with WorldPay. When I get to the accept page the Customer Information is missing. Your form generator for worldpay requires that the street address is supplied and this field is obviously empty. Your form generator creates the message:

    Argument street address must not be null or empty

    I think this and the formatting issue with quantities is what is causing all my issues. In fact when I click back to customer details they are all missing.

    Any ideas on the timescales for a fix?

  • Anders Burla 2560 posts 8256 karma points
    May 03, 2013 @ 13:26
    Anders Burla
    0

    About the street address for WorldPay is required. That is their API that is telling that.

    What is missing when you click back?

    About the quantity. Could you try and test how you would then send a decimal number or if that is not possible with PayPal.

    Kind regards
    Anders

  • Anders Burla 2560 posts 8256 karma points
    May 03, 2013 @ 13:29
    Anders Burla
    100

    The Paypal one didn't get in 2.1.1 that just released.

  • Michael Sims 119 posts 387 karma points
    May 03, 2013 @ 14:35
    Michael Sims
    0

    Hi Anders,
    When I complete the stage 2 customer information and click to shipping/payment and then click back to stage 2 the customer information is empty.

    I have tried this on a fresh starter kit install of of 2.1.0 with the upgrade to 2.1.1

  • Anders Burla 2560 posts 8256 karma points
    May 06, 2013 @ 08:52
    Anders Burla
    0

    Hi Michael

    That is properly because of browser caching because the update of the order properties happens via ajax. Try and go back to step 2 and then hit F5 to see if the info is there. Not much to do about it because the browser choose how the cache happens.

    Kind regards
    Anders

  • Michael Sims 119 posts 387 karma points
    May 06, 2013 @ 14:10
    Michael Sims
    0

    Hi Anders,

    It's definately not the browser cache as these details don't make it through to the payment stage and therefore the WorldPay fails as an address is not passed through. Could it be due to the fact that I am using Umbraco 6 set to MVC rather than WebForms? The only difference I can see between this version and a test version I have set up is that the return URL for the 302 after the post of the form has a full path ie. 

     

    http://sims.demoville.co.uk/en/shop/cart/shippingpayment/

    whereas my problem site has a return URL of:

    /basket/information

    Any ideas? I've run out of ideas.

  • Anders Burla 2560 posts 8256 karma points
    May 06, 2013 @ 14:21
    Anders Burla
    0

    Do you have a live site that I can test and a guide to how to reproduce?

    Kind regards
    Anders

  • Michael Sims 119 posts 387 karma points
    May 06, 2013 @ 14:32
    Michael Sims
    0

    Yep.

    Go to http://forgen.demoville.co.uk/our-products/solar-pv/rigid/ and choose "Add to basket". Then click on the basket on the right-hand side and when it pops out choose "Proceed to checkout". Next click "Delivery details" and enter some address information then submit the form using the "Method / Shipping" button.

    On the next screen choose "Accept" then you will see that only the Country appears to be getting set.

  • Michael Sims 119 posts 387 karma points
    May 06, 2013 @ 14:42
    Michael Sims
    0

    I've identified that order.Properties.Count is equal to 0 after submitting that information. That doesn't seem right.

  • Michael Sims 119 posts 387 karma points
    May 06, 2013 @ 15:02
    Michael Sims
    0

    Hi Anders,

    I installed the starter kit and replaced the dlls with the ones from 2.1.1 and I got the same thing happen.

  • Anders Burla 2560 posts 8256 karma points
    May 06, 2013 @ 15:06
    Anders Burla
    1

    That is because the order property format was changed in 2.1 - so that is why it doesnt work. Check the new format here:
    http://documentation.teacommerce.net/html-api/order-property/addorupdateorderproperties/

    And be sure always to check the revision history before doing an update:
    http://documentation.teacommerce.net/revision-history/

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft