"---please make a choise---" prestashop form - prestashop

i would like to make default "---please make a choice--'. Actually in checkout adress form state is compilate like italia. I put a screenenter image description here

You need to find block responsible for showing province field and add something like this right above foreach loop:
<option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
Example based on "Select a country" located in prestashop\themes\classic\templates_partials\form-fields.tpl:
{block name='form_field_item_country'}
<select
class="form-control form-control-select js-country"
name="{$field.name}"
{if $field.required}required{/if}
>
<option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
{foreach from=$field.availableValues item="label" key="value"}
<option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
{/foreach}
</select>
{/block}

Related

vuejs different v-ifs from a previous select

I am trying to display two different divs according to a select options, but I am only getting the first v-if. When I select "de", I do get the first div content, but I also get it when I select fr, instead of the second div.
I can't get my head around this. Any ideas of what I am getting wrong?
This goes on inside a form:
<select v-model="source" :key="source">
<option :value="de">de</option>
<option :value="fr">fr</option>
</select><br><br>
<div class="characters">
<div v-if="source === de" class="deChars" :key="source">
<h5>Special German characters:</h5>
<li v-for="character in deChars" :key="character">{{ character }}</li>
</div>
<div v-else-if="source === fr" class="frChars" :key="source">
<h5>Special French characters:</h5>
<li v-for="character in frChars" :key="character">{{ character }}</li>
</div>
<br>
</div>
on the script section I am using the options api with the data property source=" ", and two arrays for deChars and frChars.
note: those :key="source" I added to make sure it gets read when the source value changes.
The data properties:
data(){
return {
original: "",
translation: "",
source: "",
target: "en",
deChars: ["ä", "Ä", "é", "ö", "Ö", "ü", "Ü", "ß"],
frChars: ["à", "â", "ç", "é", "è", "ê", "ë", "î", "ï", "ô", "û", "ü", "œ"]
}
},
Thank you so much!
Try to remove the binding sign since it seems that de and fr are not declared as properties and they're just raw string :
<select v-model="source" >
<option value="de">de</option>
<option value="fr">fr</option>
</select>
then do v-if="source === 'de'" and v-else-if="source === 'fr'"
It seems that the problem was with the select options. THe binding seemed to mess about. Once I got rid of that, it works perfectly. So thanks for that Boussadjra. However, if on the v-if I change the de and fr to strings, it does not work. WHich is why I am adding this comment as the solution.

display specific category in prestashop tab homepage

I'd like to display in the new products tab in prestashop 1.6 homepage only products from a specific category
I use blocknewproducts_home.tpl
I tried this code below but nothing display from the category 114 (with get products attached)
{if $id_category == 114}
{include file="$tpl_dir./product-list.tpl" products=$new_products class='blocknewproducts tab-pane' id='blocknewproducts'}
{/if}
{if isset($new_products) && $new_products}
{include file="$tpl_dir./product-list.tpl" products=$new_products class='blocknewproducts tab-pane' id='blocknewproducts'}
{else}
<ul id="blocknewproducts" class="blocknewproducts tab-pane">
<li class="alert alert-info">{l s='No new products at this time.' mod='blocknewproducts'}</li>
</ul>
{/if}
Thanks for your help
try width : {if $smarty.get.id_category == 114}
Regards

call function since product-variants.tpl Prestashop

I'm creating a web in Prestashop and my problem is the next:
I has created a new table in db (mysql) called 'tallas' and I have the size's preferences of the users. Now, I need call this table since the page product-variants.tpl because I would like to put cheeked for default the option select by the customer.
I create this function in classes/Product.php
public function getTalla($id_customer){
$result = Db::getInstance()->ExecuteS('
SELECT `talla1`
FROM `tallas`
WHERE `cliente` = `$id_customer`');
return $result;
}
ok, I would like to receive for parameters the user id (I don't know how to do that yet) and I would like to receive the value of talla1 and then I would like put cheeked the option selected by the customer here in the themes/asmart/templates/catalog/_partials/product-variants.tpl in the radio.
<li class="float-xs-left input-container">
<label>
<input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
<span
{if $group_attribute.html_color_code}class="color" style="background-color: {$group_attribute.html_color_code}" {/if}
{if $group_attribute.texture}class="color texture" style="background-image: url({$group_attribute.texture})" {/if}
><span class="sr-only">{$group_attribute.name}</span></span>
</label>
</li>
Sincerely I don't know any idea to how to do that, can someone help me?
UPDATE: The problem is solved!
The problem is solved. I do that:
in classes/Product.php
public function getTalla(){
$variable = Context::getContext()->customer->id;
$result = Db::getInstance()->ExecuteS('SELECT * FROM `tallas` WHERE `cliente` = `$variable`');
return $result;
}
in ProductController.php
$this->context->smarty->assign('images_ex',$this->product->getTalla());
in product-variants.tpl
{if $images_ex[0]['talla1'] == $group_attribute.name} checked="checked"{/if}
I hope this can help someone in the future.

Selenium2Library - Safari not selecting from drop down list

I have two drop downs on a page. I need to verify that the item in drop down list 1 has a class of "selected" added to it when the item in drop down list 2 has been selected. Drop down list 1 has more than 3 options in it but I wanted to save space in the post. The first chunk of steps gets the values for all the items in the list and randomly selects one.
The second portion uses the value that was randomly selected in the first few steps to target the option and see check for the selected class to be true.
Here is the HTML:
<ol>
<li class="select input required" id="message_recipient_input">
<select id="message_recipient_id">
<option value></option>
<option value="1">Smith, Bob</option>
<option value="2">Smith, Steve</option>
<option value="3">Smith, Joe</option>
</select>
</li>
</ol>
<ol>
<li class="select input required" id="message_template_input">
<select id="message_template_id">
<option value></option>
<option value="9">Message Template</option>
<option value="10">Survey Template</option>
<option value="11">Coupon Template</option>
</select>
</li>
</ol>
Here are the steps in RF:
${RecipientCount}= Get Matching Xpath Count xpath=//*[#id="message_recipient_id"]/option
Log ${RecipientCount}
#{ValueList}= Create List
: FOR ${INDEX} IN RANGE 1 ${RecipientCount}
\ ${recipient_value}= Get Element Attribute xpath=//*[#id="message_recipient_id"]/option[contains(text(), '#')] [${INDEX}]#value
\ Log ${recipient_value}
\ Append To List ${ValueList} ${recipient_value}
Log ${ValueList}
${recipient}= Evaluate random.choice(${ValueList}) random
Log ${recipient}
Sleep 2s
Select From List id=message_recipient_id ${recipient}
Sleep 2s
${message_template_dropdown}= Select From List By Value id=message_template_id 9
Sleep 2s
${selected_recipient}= Get Element Attribute xpath=//option[#value=${recipient}] #selected
Log ${selected_recipient}
Should Contain ${selected_recipient} true
This works fine in Chrome and Firefox on Mac OS X but Safari isn't selecting any of the items in the lists. The steps pass as if it is selecting them but fails on the "Should Contain" step because ${selected_recipient} has None for the selected class.

Web driver how to select option in DYNAMIC drop down in VBA

I have this HTML
<div class="ui-widget">
<select name="calAlum" style="display: none;">undefined
<option value=""></option>
<option value="5.0">5.0</option>
<option value="5.1">5.1</option>
<option value="5.2">5.2</option>
<option value="5.3">5.3</option>
<option value="5.4">5.4</option>
<option value="5.5">5.5</option>
<option value="5.6">5.6</option>
<option value="5.7">5.7</option>
<option value="5.8">5.8</option>
<option value="5.9">5.9</option>
<option value="6.0">6.0</option>
<option value="6.1">6.1</option>
<option value="6.2">6.2</option>
<option value="6.3">6.3</option>
<option value="6.4">6.4</option>
<option value="6.5">6.5</option>
<option value="6.6">6.6</option>
<option value="6.7">6.7</option>
<option value="6.8">6.8</option>
<option value="6.9">6.9</option>
<option value="7.0">7.0</option>
<option value="7.1">7.1</option>
<option value="7.2">7.2</option>
<option value="7.3">7.3</option>
<option value="7.4">7.4</option>
<option value="7.5">7.5</option>
<option value="7.6">7.6</option>
<option value="7.7">7.7</option>
<option value="7.8">7.8</option>
<option value="7.9">7.9</option>
<option value="8.0">8.0</option>
<option value="8.1">8.1</option>
<option value="8.2">8.2</option>
<option value="8.3">8.3</option>
<option value="8.4">8.4</option>
<option value="8.5">8.5</option>
<option value="8.6">8.6</option>
<option value="8.7">8.7</option>
<option value="8.8">8.8</option>
<option value="8.9">8.9</option>
<option value="9.0">9.0</option>
<option value="9.1">9.1</option>
<option value="9.2">9.2</option>
<option value="9.3">9.3</option>
<option value="9.4">9.4</option>
<option value="9.5">9.5</option>
<option value="9.6">9.6</option>
<option value="9.7">9.7</option>
<option value="9.8">9.8</option>
<option value="9.9">9.9</option>
<option value="10.0">10.0</option>
</select>
when i click on the objetc display all the list but if a press "5" for example the list show only "5.0", "5.1" ,"5.2" etc. and when i press 5.8 only show me "5.8" llike valu to select
So i want to select any option with VBA, (whith other combox i dont have problems but with this have error)
i have tried this
sub CALF()
Dim H As selenium.Keys
*Here find the element "select" whit the name "calAlum"* i dont have problem
For Each element In WEB3.FindElementsByTag("select")
If element.Attribute("name") = "calAlum" Then
element.AsSelect.selectbyvalue Activecell *in this part show error*
End If
Next
MsgBox "fin"
End Sub
but for this drop down doesnt work i tried to use diferent ways but dont work, NOTE: this code go to inside IF
"to focus the box but dont work"
element.click
"to write value dont work"
element.sendkeys "5.8"
"to copy value in clipboard then paste value in the objetc dont work"
WEB3.SetClipBoard ActiveCell.Value
element.SendKeys Control, "V"
but if manually select any value in the object like "9.8" and the in the code use
R= element.value
or
R=elment.attrribute("value")
return "9.8" then i use
element.asselect.selectbyvalue R work
but if i change R= "9.7" and use
element.asselect.selectbyvalue R
return Error value no found
then i tried after to wrap webelement in selectelemnet this
r= element.SelectedOption
r= element.asselect.selectedoption
to know what option is selected, but both return void "" obviusly is rare because R= element.value return "9.8" then i use
element.asselect.options
for i=0 to element.asselect.options
r(i)=element.asselect.selectedoption
next
to know all option are in selectelement "element" but return error its necesary a object so use
r = element.IsSelected
but return false thats to say i cant use the object like webelement and if i wrap to selectelment the object dont have any option, someone can help me.
If you help me how to select the object o how to manipulate object "select" dynamic
CSS selector:
You can use a CSS selector to target the option of choice and then .Click to select. You extract the option value into a variable which you concatenate into the CSS selector string.
Your example:
For your example, you can use selector select option[value='5.0'], where 5.0 is extracted into a variable.
CONST SELECTED_INDEX As String = "5.0"
WEB3.FindElementByCss("select option[value='" & SELECTED_INDEX & "']").Click
Here is an example using Facebook and selecting the drop down day for birthday.
CSS selector for Facebook birthday day:
#day option[value='18']
This reads as element with id "day", containing tag option, with attribute value that is =18. # is id selector and [] is for attribute.
VBA Code:
Option Explicit
Public Sub MakeSelection()
Dim d As WebDriver
Set d = New ChromeDriver
Const URL = "https://www.facebook.com/"
Const SELECTED_INDEX As Long = 18
With d
.Start "Chrome"
.get URL
'Selector was e.g. for day 1 "#day option[value='1']"
.FindElementByCss("#day option[value='" & SELECTED_INDEX & "']").Click
Stop '<= Delete me later
.Quit
Application.ScreenUpdating = True
End With
End Sub