nwazet ecommerce

Topics: General
Feb 22, 2013 at 6:00 AM
Edited Feb 22, 2013 at 6:02 AM
Here's the shopping cart summary template:
@using Nwazet.ZenGallery.Services
@using Orchard.ContentManagement
@using System.Linq
    var items = (IList<dynamic>)Model.ShopItems;
    var subtotal = (decimal) Model.Subtotal;
    var cartUrl = Url.Action("Index", "ShoppingCart", new {area = "NWazet.Commerce"});
@if (items.Any()) {
    using (Html.BeginFormAntiForgeryPost(Url.Action("AjaxUpdate", "ShoppingCart", new {area = "Nwazet.Commerce"}))) {
        <h1><a href="@cartUrl">@T("Your Cart")</a></h1>
        <div class="minicart-scroll-zone">
            <div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div>
            <div class="viewport">
                <ul class="overview cart-item-list">
                    @for (var i = 0; i < items.Count; i++) {
                        var item = items[i];
                        var propertyNamePrefix = string.Format("items[{0}]", i);
                        var contentItem = (IContent) item.Product;
                        var title = item.Title
                                    + (item.ProductAttributes == null
                                           ? "" : " (" + string.Join(", ", item.ProductAttributes.Values) + ")");
                        string imageUrl = (item.ProductImage != null ? item.ProductImage.Url :
                                               item.ContentItem.ZenGalleryPart != null ?
                                                   ((IEnumerable<string>) WorkContext.Resolve<IZenGalleryService>().GetImages(item.ContentItem.ZenGalleryPart)).FirstOrDefault() : null);
                        var quantity = (int) item.Quantity;
                        var unitPrice = (double) item.DiscountedPrice;
                        var totalPrice = quantity*unitPrice;
                            @if (imageUrl != null) {
                                <div class="cart-product-image"><a href="@Url.ItemDisplayUrl(contentItem)" class="product-image-link"><img src="@(Href(imageUrl))" alt="@title" class="product-image"/></a></div>
                            <div class="cart-item-summary@(imageUrl != null ? " narrow" : "")">
                                <span class="action"><a class="delete" href="#">@T("Remove")</a></span>
                                <span class="price">
                                    @if (item.ProductAttributes != null) {
                                        var attrIndex = 0;
                                        var attributeNamePrefix = propertyNamePrefix + string.Format(".AttributeIdsToValues[{0}]", attrIndex);
                                        foreach (KeyValuePair<int, string> attribute in item.ProductAttributes) {
                                            <input type="hidden" name="@(attributeNamePrefix).Key" value="@attribute.Key"/>
                                            <input type="hidden" name="@(attributeNamePrefix).Value" value="@attribute.Value" />
                                    <input name="@(propertyNamePrefix + ".ProductId")" type="hidden" value="@contentItem.Id" />
                                    <span class="numeric">
                                        <input name="@(propertyNamePrefix + ".Quantity")" type="number" class="quantity" value="@quantity" />
                                    <span class="numeric amount">@totalPrice.ToString("c")</span>
                                <a href="@Url.ItemDisplayUrl(contentItem)" class="product-name">@title</a>
        <div class="total">
            <button name="command" value="Update" type="submit" class="update-button">@T("Update All")</button>
            <span class="numeric label">@T("Subtotal:")</span>
            <span class="numeric subtotal">@subtotal.ToString("c")</span>
        <span class="explanation">@T("Tax and shipping will be calculated at checkout.")</span>
    <div class="checkout">
        <a class="button" href="@cartUrl">Checkout</a>
Take what you need from that, but be careful about the last div with class checkout: replace it with the current checkout code, as this one is relying on a feature that I haven't released yet.
Mar 4, 2013 at 10:35 AM

Appreciate guidance...

Is there some instructions how to set up the nwazet.commerce (doc, video etc.), theme ?
Mar 4, 2013 at 6:10 PM
No, there is no documentation except for a couple of blog posts. Is there a specific problem I can help you with?
Mar 5, 2013 at 10:10 AM
First - thank's for rapid reply and support...

Many thank's for your tip. I had previously looked at the "Orchard Harvest 2012..." but was not aware of Bertrand's "Building a complete e-commerce..." which explained a lot.

I guess that rendering the product content type list (images float left and add-to-cart float right) is with a themed template!?

Is it possible to download/recieve the Orchard.Theme.Nwazet NUPKG file? I would really appreciate that as a working platform.
Mar 7, 2013 at 3:39 PM
Finally resolved most of issues by learning, trial and error - I forgot the placement.info file super functionality!

Still a question: I supress metadata by "Parts_Common_Metadata="-"". This effects the detail rendering but not the summary (list).

How do I supress metadata in Product list?
Mar 7, 2013 at 6:18 PM
You can match on DisplayType Summary.
Mar 7, 2013 at 10:08 PM
Edited Mar 7, 2013 at 10:12 PM

Content type Product front end list still display the meta data:
"<div class="published">Mar 5 2013 6:47 PM</div>"

"<Match DisplayType="Summary">"
" <Place Parts_Common_Metadata="-"/>"
Mar 7, 2013 at 11:35 PM
Here is the section of placement.info I use in my own theme:
<Match ContentType="Product" DisplayType="Summary">
  <Place Parts_Title_Summary="Header:1"/>
  <Place Parts_Title="-"/>
  <Place Parts_Common_Metadata_Summary="-"/>
  <Place Parts_Comments_Count="-"/>
  <Place Parts_Product="Header:2"/>
  <Place Fields_MediaPicker-ProductImage="Images:1"/>
  <Place Parts_ZenGallery="Images:1;Alternate=Parts_ZenGallery_Thumbnail"/>
  <Place Parts_Product_AddButton="Specs:1"/>
  <Place Parts_GoogleCheckout="Specs:1"/>
  <Place Fields_Contrib_TaxonomyField-ProductType="-"/>
  <Place Fields_Contrib_TaxonomyField-Labels="-"/>
  <Place Parts_Tags_ShowTags="-"/>
  <Place Fields_Boolean-Pinned="-"/>
Mar 12, 2013 at 8:34 AM
Thank you for advice/sample!

I wonder if you consider to release a theme that utilises the Nwazet.Commerce and Nwazet.ZenGallery modules (?) - it would be very beneficial.
Mar 13, 2013 at 12:26 AM
Sure, I'll release the Nwazet theme when I'm done with the big changes that are coming up in Nwazet.Commerce.
Mar 13, 2013 at 9:41 AM
Edited Mar 13, 2013 at 9:43 AM
Thank's for reply and looking forward to the new Theme!

Translations have no effects ie. as below - how come?

"#": Nwazet.Commerce.Menus.ProductAdminMenu
"#"| msgid "Commerce"
msgctxt "Nwazet.Commerce.Menus.ProductAdminMenu"
msgid "Commerce"
msgstr "E-handel"'
Mar 14, 2013 at 5:19 AM
Just in this module or everywhere? Are you sure you put the translation files at the right place?
Mar 14, 2013 at 9:54 AM
Translation is downloaded from Orchard Translate site.

Translation works fine in module(s) else. The example above is taken from Nwazet.Commerce/App_Data/Localization/sc-SW/orchard.module.po and does not work.
Mar 14, 2013 at 6:54 PM
Then I don't know, sorry.
Mar 17, 2013 at 9:09 AM
Ok Bertrand - will dig deeper in this. But I have another issue...

I have set the Product type as Bertrands video on Youtube chanel (using Zen Gallery) and run in a shared hosting environment.
Leaving the "Gallery Image Path" empty will not generete the path and is not visible when editing (fieldset does not render) !?
If adding any character (even if not the path) in field it remains visible when edit.

Is there some explanation to this?
Mar 19, 2013 at 7:34 AM
I don't know. It works just fine for me. Attach a debugger maybe?
Mar 19, 2013 at 7:23 PM
As I said, you probably need to attach a debugger to find out what's wrong here.