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+:
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.
[SuppressDependencyAttribute( "TeaCommerce.Api.PriceCalculators.IShippingCalculator", "TeaCommerce.Api" )] public class OwnCustomShippingCalculator : ShippingCalculator {
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).
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'.
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.
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.
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.
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
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.
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.
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.
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?
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+:
/Rune
Is there a way to override the shipping cost calculation?
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
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.
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?
Hi Michael
Custom shipping provider:
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
Thanks for the example. I've tried adding it but I am getting the following error:
Have you updated to Tea Commerce 2.1?
/Rune
No. Do I need to update?
Yes you need to do that. The suppress dependency is added in 2.1
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>
Never mind. I touched the config and everything magically started working again.
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.
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
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.
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?
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
The Paypal one didn't get in 2.1.1 that just released.
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
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
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.
Do you have a live site that I can test and a guide to how to reproduce?
Kind regards
Anders
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.
I've identified that order.Properties.Count is equal to 0 after submitting that information. That doesn't seem right.
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.
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
is working on a reply...