Product Option Question

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hello guys,

I'm trying to find a way to make the Product Options (Attributes) react a bit differently. I am using Nop 4.0 on a live server. On the product attributes, (Under control type) when using the drop down menu to assign specifications it allows the customer to "Add to Cart" without making a selection. I need it to stop the customer and either through the red error bar on my theme or a pop-up box has to appear and let the customer know to select an option.

I've noticed this issue doesn't occur when I select Radio Boxes, it still stops the customer then, and that's the type of functionality we need.

As of right now, I just created a simple product called No Thanks without an associated SKU to simulate our original site. We need it to at least function like https://tinyurl.com/yd4akv9k and currently this is our NOP implementation https://tinyurl.com/yc42xtgc

I found a thread with an edit for the "No Pre-select" option and tried the code, it didn't work though. Here is a link to that https://tinyurl.com/ycb5eow9

Has anyone found a work around for this?
5 years ago
Chances are your theme already overrides the View. So you must edit Nop.Web\Themes\YOUR_THEME\Views\Product\_ProductAttributes.cshtml instead.

PS:/ Here's more explanation on theme overrides - https://stackoverflow.com/questions/12266717/html-to-nopcommerce-theme/12740727#12740727


5 years ago
wooncherk wrote:
Chances are your theme already overrides the View. So you must edit Nop.Web\Themes\YOUR_THEME\Views\Product\_ProductAttributes.cshtml instead.

PS:/ Here's more explanation on theme overrides - https://stackoverflow.com/questions/12266717/html-to-nopcommerce-theme/12740727#12740727





Hey Woon,  I am working with Daniel on this, I understand it needs to be modified at the specific theme per the specific store, but i have a question about the change in the code - there are a few posted solutions about this. What one is correct?


https://www.nopcommerce.com/boards/t/38066/needing-no-pre-select-for-dropdown-attribute.aspx

https://www.nopcommerce.com/boards/t/49813/product-attribute-control-drop-down-list.aspx
-
https://www.nopcommerce.com/boards/t/17731/how-to-force-product-variant-attribute-selection.aspx


Every post says something a little different.


Option 1 states to remove "!" (this is the one we did)
Posted by Raju

Go to "\Nop.Web\Views\Product\_ProductAttributes.cshtml"

and update below code under  
case AttributeControlType.DropdownList: { ... ... ...}


Line number 36 (nopCommerce 3.90)


@if (!attribute.IsRequired)
{
     <option value="0">---</option>
}

to


@if (attribute.IsRequired)
{
     <option value="0">---</option>
}



Just remvove "!" from if condition


The second way it is posted is this
From L.K

1. Open: Nop.Web\Views\Product\_ProductAttributes.cshtml

2. Replace


@if (!attribute.IsRequired)
{
   <option value="0">---</option>
}

with

<option value="0">---</option>



(Make sure all options / values in your dropdown menu are "NOT" pre-selected)

And the third one we found was from @a.
m

In this case try the following:
1. Open \Views\Catalog\_ProductAttributes.cshtml (Nop.Web project)
2. Replace
@if (!attribute.IsRequired)
{
   <option value="0">---</option>
}

with
<option value="0">---</option>

P.S. I haven't tested it.

The last one was from Andrei
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.