Developer forum

Forum » Templates » Variant Option Name has whitespace removed

Variant Option Name has whitespace removed

Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

In the DB, we have a number of VARIANTOPTIONNAMEs with spaces, but when these are presented to the swift template 

case VariantGroupDisplayType.VariantName:
<span class="d-flex align-items-center justify-content-center">@(option.Name)</span>
break;

The spaces are removed, so the variant options look odd.

Its not a big deal at the moment, as we have an integer and a unit, without a space, which reads "ok" but not perfect.  Like 5LTR, 10LTR etc.  But if we start having other options such as   "BLAH BLAH FOO", then "BLAHBLAHFOO" will be completely wrong

( https://doc.dynamicweb.com/template-tags/ecommerce/product-catalog/product/variantgroups/variantavailableoptions#Ecom:VariantOption.Name )

I dont understand why the name has its spaces removed when it appears to tbe the variantoption id which is used for reference anyway

Cheers

 

 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Stephen

Just went through the code and we should not remove any spaces from the name property, and I do not have the mentioned issue.

Can you show me the raw data for all language versions of the option from your database:

And just to be completely sure - have you checked the dev tools in the browser that is not a rendering error - e.g. that 'word-spacing' is not set to 0 for the text block that contains the name of the option?

Feel free to share a link to the issue so we can check it out.

 

 

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Hei Nicolai.

There is no word-spacing style set no. Its the standard swift button used in the variant selector. (Swift/Components/VariantSelector.html) The name is clearly the ID (which is the same string, but without spaces) The code snippet below shows option.name being used, but for some reason, the ID is in this field. I suspect the VariantOptionViewModel is mapping the ID to the name

DW version is 9.17.3

Example Link

https://www.valvoline.no/synpower-0w-40-1ltr-1

See attached picture for rows in variantsoptions table

Relevant Code snippets from template

foreach (var variantGroup in productVariantGroups)
{
VariantGroupViewModel group = variantGroup;
foreach (var option in group.Options)
{
  switch (displayType)
{
    case VariantGroupDisplayType.VariantName:
<span class="d-flex align-items-center justify-content-center">@(option.Name)</span>
break;
}}}
variantsoptions.png

 

You must be logged in to post in the forum