Jordan King
2018-01-22T16:47:27Z
Hello,

I have a client who wants to have the quantity hidden in the product details. The reason is my client only provide one of a kind artwork and never prints or anything similar. My client's customers have asked why there is a quantity available and if that means what they are buying is not one of a kind.

I can see the following property for the product object: Hotcakes.Commerce.Catalog.Product
public bool HideQty { get; set; }

and I can see the following check in the product details view of the default viewset: _ProductDetails.cshtml
notice the check of the VM property Model.LocalProduct.HideQty

            if (!Model.LocalProduct.HideQty)
            {
                <div class="dnnFormItem">
                    <label class="dnnLabel" for="qty">@Localization.GetString("Quantity")</label>
                    <input type="text" id="qty" name="qty" value="@Model.InitialQuantity" class="hc-input-mini" />
                </div>
            }
I can not see where to set this value. Can someone help me understand this property and tell me if there is a way I can set this myself for products in the store?

Thanks
Scippy
  •  Scippy
  • 100% (Exalted)
  • Advanced Member
2018-01-23T16:21:43Z
If you want hide quantity text on product details you can simply change the above code in this way:

if (!Model.LocalProduct.HideQty)
            {
                <div class="dnnFormItem" style="display: none">
                    <label class="dnnLabel" for="qty">@Localization.GetString("Quantity")</label>
                    <input type="text" id="qty" name="qty" value="@Model.InitialQuantity" class="hc-input-mini"/>
                </div>
            }

or in this way:


<input type="hidden" id="qty" name="qty" value="@Model.InitialQuantity" class="hc-input-mini"/>
Jordan King
2018-01-23T16:54:23Z
thanks scippy,

I am comfortable changing the code in the viewset to "hide" this input. Over the last day's research, I have found that this bool value can only be set when the product is marked as allowing a user-supplied price. I was hoping there was some way to do this from the Store Admin Pages because then it would allow it to be applied to specific products. If I change the viewset then I have to create a different view for each product type based on whether or not I want the quantity displayed.

Unless someone else has an idea of how to do this from the admin pages I think I have to use the method you outlined.
Scippy
  •  Scippy
  • 100% (Exalted)
  • Advanced Member
2018-01-24T11:17:00Z
Hi Jordan,
to archive this from the Store Admin Pages you can simple create two templates in Products view folder, one with quantity (index) and one without quantity(indexNoQTY), remember you have also to add a new _ProductDetailsNoQTY (where you hide the quantity) and add localization files in LocalResources folder.
After in Store Admin product page you will be alble to select the Template you want for each product.
Will Strohl
2018-02-08T21:39:20Z
Scippy's advice is spot-on. The hidden field value is probably going to be the better solution. You'll also need to update the cart view since it also exposes the quantity field along with an update action.

If this is a mission-critical site, I'd also suggest creating an action delegate to ensure that the quantity is always one upon adding the product to the cart and going to the checkout from the cart. This will prevent any tampering.

https://hotcakescommerce...line-Integration-Project 
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Jordan King
2018-02-13T18:41:06Z
thank you everyone,

I ended up just changing the product details view for those products and hiding (hidden field) the quantity.

J
Will Strohl
2018-02-23T00:08:52Z
Good stuff, Jordan. Thanks for the update! 🙂
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Loading
  • Sign-up for the Hotcakes Community Newsletter: