I am trying to display a dropdown with all the countries that prestashop has in his database.
When a customer is adding a new address, a field ask for the country, but displays only United States.
How can I make to display all the countries?
Because when I edit the customer I can see all the countries.
What I have tried:
In the location: /public_html/Project/themes/myTemplate/templates/_partials/form-fields.tpl
I realized there is a Foreach to fill the dropdown, but load United States.
{elseif $field.type === 'countrySelect'}
{block name='form_field_item_country'}
<select
class="custom-select js-country"
name="{$field.name}"
{if $field.required}required{/if}
>
<option value disabled selected>{$field.label}</option>
{foreach from=$field.availableValues item="label" key="value"}
<option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
{/foreach}
</select>
{/block}
I can see in console, actually, loads one value only.
Could anybody has the same error?
How can you help me to fix it?
Go in International > Locations , check Countries tab and make sure the other countries are active (they aren't in a standard US / UK Prestashop installation)
Related
Do you know how to add and show shipping costs in checkout summary, ONLY after an address (with county) is added/selected, on Prestashop 1.7.6?
Is it possible?
You make your country have county as requirement.
You edit the corresponding .tpl (which serves the shipping cost)
{if !isset($address)}
<span class="alert alert-warning">
{l s='Choose address to see the shipping cost'}
</span>
{else}
{* Here the actual content *}
{/if}
Regards,
Konstantinos A. Kogkalidis
I am trying to add a currency selector on one of my custom pages where I have displayed the product details.
I want to allow my visitor to change the default currency from this custom page and view the product pricing accordingly.
I have added this code in my custom.tpl
<input type="hidden" name="token" value="{$LANG.go}">
<select name="currency" onchange="submit()" class="form-control">
<option value="">Change Currency (A$ AUD)</option>
{foreach from=$currencies item=listcurr}
<option value="{$listcurr.id}"{if $listcurr.id == $currency.id} selected{/if}>{$listcurr.prefix} {$listcurr.code}</option>
{/foreach}
</select>
</form> ```
But it is not working, every time I select the currency from the dropdown, it refreshes the page. but nothing changes,
please guide what I am doing wrong.
Thanks in advance
Aqsa,
You can do this. You could update your form to either:
Perform a GET request, and add the currency=$id parameter to the URL ($id being the ID for the currency in tblcurrencies.
Or
When your form submits, handle the form input, and set the currency in the session variable:
use WHMCS\Session;
Session::set('currency', $id);
Again, where $id relates to tblcurrencies.id.
Bare in mind that the currency cannot be changed for existing users, and it is not recommended changing their currency after they have made any transactions to avoid accounting/calculation issues.
Hello I am using menu for mobile for prestashop 1.6 website.
I want to shange displayed name of categories.
I created name2 field for ps_category_lang table and filled with shorter category names. I want to show short names af mobile menu.
{foreach $subcategories as $subcategory}
{if ($subcategory->id|escape:'htmlall':'UTF-8') ne '45'}
<li {if count($subcategory->getChildrenWs())}class="icon-arrow"{/if}>
<a
class="rm-level__item rm-category-{$subcategory->id|intval}"
{if $subcategory->nright > $subcategory->nleft +1}data-load="{$subcategory->id|escape:'htmlall':'UTF-8'}"{/if}
href="{$subcategory->getLink()|escape:'htmlall':'UTF-8'}"
>{$subcategory->name|escape:'htmlall':'UTF-8'}</a>
</li>
{/if}
when I change $subcategory->name to $subcategory->name2 menu shows empty category names.
https://addons.prestashop.com/en/mobile/17310-menu-for-mobile.html
where this subcategories created?
You also have to modify (preferably and most recommended, override) the Category.php (in classes) class and add the field name2 in the Lang fields definition of the model.
I have just downloaded and installed the latest version of Prestashop. And found out there is a Social Title-option in order checkout form.
I want to remove that. I have found how to remove the Mr and Mrs boxes. But the whole row and label "Social Title" remains.
Have tried to search on Google for an answer but can't find. Some answers refer to the addresses.tpl. But I think the templates might been changed since these threads.
In fact, I have tried to search for "social" in the whole template directory and can't find anything related to this.
The nearest I get is in the ../templates/customer/_partials/customer-form.tpl. And I think it's rendered where this is:
<section>
{block "form_fields"}
{foreach from=$formFields item="field"}
{block "form_field"}
{form_field field=$field}
{/block}
{/foreach}
{/block}
</section>
So, maybe the social title isn't able to change from templates anymore?
So, where do I change it nowadays?
In Prestashop 1.7 there is no need to edit any code, you can just go to Shop Parameters -> Customer Settings -> Titles and remove all existing titles.
This will prevent the "Social title" field from being generated.
Shop Parameters -> Customer Settings -> Titles - Delete titles
themes/xxx/templates/_partials/form-fields.tpl 9th line change
{if $field.type !== 'checkbox'}
{$field.label}
{/if}
to
{if $field.type !== 'checkbox' and $field.type !== 'radio-buttons'}
{$field.label}
{/if}
Yeah, it's kind of dummy workaround, but it works.
UPDATE:
More proper way would be to comment the block:
$genderField = (new FormField)
->setName('id_gender')
->setType('radio-buttons')
->setLabel(
$this->translator->trans(
'Social title', [], 'Shop.Forms.Labels'
)
)
;
foreach (Gender::getGenders($this->language->id) as $gender) {
$genderField->addAvailableValue($gender->id, $gender->name);
}
$format[$genderField->getName()] = $genderField;
You can find it in /classes/form/CustomerFormatter.php
You can find the code for Social Titles in file at the following path:
/themes/default-bootstrap/identity.tpl
Note: It is not a good practice to remove the code from a core file, we recommend to apply some CSS to hide the Social Title block.
I have a problem regarding a webpage that I´m currently working on.
The theme that I´m working the site with is gameguru 1.5 and the matter is that on the final row of my product-list, when I get to the bottom of it, there are 2 products appearing instead of 3.
The relevant code of the source file (product-list.tpl) is this one:
{if isset($products)}
<!-- Products list -->
<div id="product_list" class="clear category_list product_list grid row">
<div class="inner-product-list">
{foreach from=$products item=product name=products}
<div class="ajax_block_product {if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if} {if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix col-xs-6 col-sm-6 col-md-4">
I´ve tried several things but I´m quite stuck here.
Finally, I would like to include one product list of the webpage in order to give you a bit more guidance.
http://tutiendadevideojuegos.com/127-ps4-videojuegos-ps4
I would appreciate very much any help.
Thanks,
Orestis
try this part
{if $smarty.foreach.products.index % 2}alternate_item{else}item{/if}
change to
{if $smarty.foreach.products.index % 3}alternate_item{else}item{/if}
UPD:
to manipulate number of products per page, in backoffice Preferences -> Products option "Products per page" put there e.g. 12 and you will have 3 products in all lines + correct values in dropdown.