I am using Prestashop 1.7.1.1 and I need to force my shop customers to select country. Now it is always pre selected as my store default country (in my case Lithuania). Option to enable "Set default country from browser language" via International > Localization is not acceptable because a lot of customers is using browser language English, but real country is not United States or United Kingdom. For me it will be the best to set --please chose-- as pre selected value and force customer to select one from the list.
You can disable this behaviour by enabling first select themes\classic\templates_partials\form-fields.tpl if you use classic theme.
An alternative may be to use jQuery :
$("#id_country option:first").prop('disabled',false);
$("#id_country").val($("#id_country option:first").val());
Related
I have created one custom module in Prestashop 1.7.8.7 which will add multiple shipping methods (Carrier) and will show shipping cost based on product dimensions and delivery address. So shipping carrier will look something like this on front-end checkout page. https://prnt.sc/E1avDASyJYYW
Now if someone select SameDay Courier Shipping then i need to show two radio button to select which service they want.
It will have two radio options like
Delivery pickup (by default this option will be selected)
Locker pickup
So if someone select Delivery pickup then it will have different shipping cost and if someone select Locker pickup then it will have different shipping cost.
Can anybody help me how can i achieve this functionality.
While digging, i found that we have file called DeliveryOptionsFinder.php and in that file we have one public function called getDeliveryOptions() where we have this line of code
if ($moduleId = Module::getModuleIdByName($carrier['external_module_name'])) {
$carrier['extraContent'] = Hook::exec('displayCarrierExtraContent', ['carrier' => $carrier], $moduleId);
}
}
So if i set is_module to 1 to all my carriers directly from DB then on frontend checkout page, no carriers is being displayed.
Thanks in advance.
I've already done something like this in the last 2 year as prestashop developer.
The truth is that you can't achieve what you want by "respecting" prestashop processes.
Maybe you can hook using a module the hookDisplayCarrierExtraContent($data) and then return the 2 radios if carrier is certain one (use $data).
But you can't handle a form submit or something else, or include it to prestashop checkout data.
But what you can do as workaround, for example, is the following.
In your module, as I said, hook the extra content, render a template with the 2 radios. Hook displayHeader too and use $this->context->controller->addJS() to add your own js if the current controller is the checkout one.
Then in this JS code you can handle the "change" event of the radios and send an ajax request to your module.
You can create inside {your_module}/controllers/front/ a controller called, for example, radio-choose and handle the js ajax request by saving inside your own table the choosen one.
Obviously you can disable the "next" button in checkout untill one of the two radios are selected, or maybe you can just set a radio button as default one to simplify.
For example your table "ps_cart_choosen_radio" could look like this |id_cart|choosen_radio|.
Then you have all the data you needed. When a cart is converted into an order you will have inside Order object (and ps_orders table as well) the id_cart.
Just select / join choosen radio from your own table by using order's id_cart.
"SELECT choosen_radio FROM ps_cart_choosen_radio WHERE id_cart = {$order.id_cart}"
If you need to show data depending on choosen_radio in frontend you can hook everywhere an order is present and select these data. Or maybe you can edit carrier name in ps_orders table by adding a piece of string. Let' say carrier is "express" and customer choosed "24h". You can update that column with carrier name by changing it to "express-24h" so around the whole prestashop ecosystem everybody will see that's a 24h choice.
Remember that the carrier name related to an order is not the carrier name inside the carriers table. So you can edit it without having trouble.
All these problems comes from the "need" to show some nested choices instead of listing all these in the main selections. In that case it would be easy (just create carrier in the prestashop backoffice)
I use prestashop 1.7.3.3 e-commerce system.
I need to get a phone number from the customer.
Phone field looks optional. I want to make it mandatory.
How can i do that?
enter image description here
You can set that field as mandatory in the BO > Customers > Addresses.
I want to do a search for products. I also get some results but they are located in the USA with currency USD but I want to get results from Germany with EUR instead. The language of the custom search is already set to German but the prefered search results are from US.
Is there a possibility to prefere german sides only?
Thanks for your answeres!
You could restrict or boost results from Germany with cr or gl attribute.
cr Restricts search results to documents originating in a
particular country.
gl Boost search results whose country of origin matches the
parameter value.
So, you could try:
<gcse:search cr="countryDE"></gcse:search>
Or:
<gcse:search gl="de"></gcse:search>
Custom Search Element Control API / Supported Attributes
https://developers.google.com/custom-search/docs/element#supported_attributes
If you don't need "global" search, and all, or the most of your CSE implementations should be restricted to Germany, then you could set default cr or gl on https://cse.google.com/ > Search features > Advanced > Websearch restricts. ("Country Restrict" and "Boost Results By Locale".)
I can select a currency with a currency column but the value is always in USD, is it possible to change the currency iso code?
E.g. $39.99 this is in Canadian dollars but always appears 39.99 USD.
I see you can use text but then i am stuck with the $ symbol.
Right now i have had to use a regular expression to drop the $
What is happening is that the price you see is through your own IP address, but when you run your API you are calling the API on our American servers for you. The website registers our servers' US IP address and display their price in US dollars instead. Unfortunately, at this time, you cannot change the currency.
If you are using a Crawler, in the Advanced Options (by toggling the Simple button to Advanced), choose to crawl Locally instead, this will use your own IP address, and should therefore display the price in your desired currency.
Thanks,
Meg
i want to change list sequence of field register in prestashop 1.6 like country - state - city, i have tried edit in themes - default-bootsrap - address but cannot work
You have to change in to backoffice:
Localization -> Countries -> Edit the active country that you want to change the list
Then in Address format you can choose the order, change, and remove.