Categorías
Prestashop

¿Cómo detectar si es un móvil en Prestashop con .tpl?

Descubre cómo utilizar las clases de Prestashop para detectar el dispositivo utilizado y poder mostrar o no textos, imágenes, funciones adicionales de forma correcta y eficaz

Además de utilizar un tema responsive, que se adapta según el tamaño del dispositivo que utilice el usuario, puede ser útil para detectar si el dispositivo es un smartphone, una tablet o un ordenador.

En un tema receptivo, generalmente, usamos la técnica de no mostrar ciertas partes de la página en algunos dispositivos simplemente escondiéndolas a través de algunas reglas de hojas de estilo (css): esta solución no aligera el peso de las páginas porque el código oculto será de todos modos presente en la página y tan cargado por el navegador.

En cambio, mediante la detección del dispositivo utilizado, es posible que se muestren o no textos, imágenes, funciones adicionales, etc. de forma correcta y eficaz.

Prestashop 1.7.x y Prestashop 1.6.1.x

Estas versiones de Prestashop ya utilizan una clase para detectar el dispositivo utilizado (/classes/Context.php), gracias a la cual podemos consultar directamente en los archivos .tpl de nuestro tema.

Detectar un teléfono inteligente

{if Context::getContext()->isMobile() && !Context::getContext()->isTablet()}
  tu contenido
{/if}

o

{if Context::getContext()->getDevice() == 4}
  tu contenido
{/if}

Detectar una tableta

{if Context::getContext()->isTablet()}
  tu contenido
{/if}

o

{if Context::getContext()->getDevice() == 2}
  tu contenido
{/if}

Detectar una computadora

{if !Context::getContext()->isMobile() && !Context::getContext()->isTablet()}
  tu contenido
{/if}

o

{if Context::getContext()->getDevice() == 1}
  tu contenido
{/if}

Prestashop 1.6

Detectar un dispositivo móvil

{if isset($mobile_device) && $mobile_device}
  tu contenido
{/if}

Categorías
Prestashop

Como se quita del producto «Impuestos incluidos» de Prestashop

En el panel de Gestión de Prestashop en Internacional > Ubicaciones geográficas > Países > Busca el país, seleccionas modificar y luego desmarcas la opción «Mostrar la etiqueta de impuestos (por ejemplo, «Impuestos incl.»)«

Categorías
Prestashop

Descargar PsCleaner para Prestashop 1.7

PrestaShop PsCleaner le ayuda a eliminar su catálogo, pedidos y datos de clientes de una sola vez.

Muy útil recién instalado el prestashop, ya que borrada todos los datos de demo incluidos en la instalación por defecto.

Este módulo no es compatible con multitienda, significa que su configuración se aplica a todas las tiendas.

Actualizado el 11 de Junio de 2020

Categorías
Prestashop

Como insertar style en archivos tpl de prestashop

Para usar estilos en archivos tpl, tiene que englobarlo con estas etiquetas {literal} {/ literal} estas etiquetas son necesarias porque el código de estilos css usa corchetes, por lo que el compilador inteligente trata estos corchetes como una sintaxis inteligente.

{literal}
<style>
.swiper-pagination-progressbar{background:#000}
</style>
{/literal}
Categorías
Prestashop

Como eliminar la categoría de inicio de todos los productos

En phpMyAdmin o en tu gestor de SQL, ejecutar la siguiente SQL

DELETE FROM 'ps_category_product' WHERE 'id_category' = 2;

Cambie ps_ por el prefijo de su base de datos, si es necesario.

Categorías
Prestashop

Crear un usuario en PrestaShop manualmente con SQL

No funciona en la versión 1.7.6.7

INSERT INTO `ps_employee` (`id_employee`, `id_profile`, `id_lang`, `lastname`, `firstname`, `email`, `passwd`, `last_passwd_gen`, `stats_date_from`, `stats_date_to`, `stats_compare_from`, `stats_compare_to`, `stats_compare_option`, `preselect_date_range`, `bo_color`, `bo_theme`, `bo_css`, `default_tab`, `bo_width`, `bo_menu`, `active`, `optin`, `id_last_order`, `id_last_customer_message`, `id_last_customer`, `last_connection_date`, `reset_password_token`, `reset_password_validity`) 
VALUES ('2', '1', '1', 'Apellidos', 'Nombre', 'correo@correo.com', 'ef6ba3bc958176483aa342396e580ff5', '2020-09-23 12:03:21', '2020-08-23', '2020-09-23', '0000-00-00', '0000-00-00', '1', NULL, NULL, 'default', 'theme.css', '1', '0', '1', '1', '1', '0', '0', '0', NULL, NULL, '0000-00-00 00:00:00');

Vamos a ver los valores importantes

Hay que modificar el primer elemento que es un 2 por el siguiente id de la tabla, cambiamos el correo y el siguiente campo que es la contraseña en MD5 (entras en https://md5online.es/cifrar-md5 escribes la contraseña y descifrar el resto lo dejamos igual

INSERT INTO `ps_employee_shop` (`id_employee`, `id_shop`)
VALUES ('2', '1');

En la siguiente consulta hay que cambiar el primer 2, por el numero que hemos cambiado anteriormente

Categorías
Prestashop

Uncaught Error: Class ‘Tools’ not found. classes/db/Db.php:794

Localize en su servidor el fichero Db.php que se encuentra en /classes/db/Db.php

Busque Tools::nl2br en el código y cambiarlo por nl2br

Antes del cambio

$string = strip_tags(Tools::nl2br($string));

$string = strip_tags(Tools::nl2br($string));

Después del cambio

$string = strip_tags(nl2br($string));

Categorías
Prestashop

Variables globales Prestashop

{$currency.name} -> Name of the active currency. 
{$currency.iso_code} -> ISO language code enabled. 
{$currency.sign} -> Symbol of the active currency 
{$currency.iso_code_num} -> Active Currency ISO Code

{$shop.name} -> Store name in Prestashop 1.7 
{$shop.email} -> Store Email in Prestashop 1.7 
{$shop.logo} -> Image routing store logo in Prestashop 1.7 
{$shop.favicon} -> Route favicon image of the store in Prestashop 1.7 
{$shop.address.address1} -> Store address 1 in Prestashop 1.7 
{$shop.address.address2} -> Store address 2 in Prestashop 1.7 
{$shop.address.postcode} -> Store Zip Code in Prestashop 1.7 
{$shop.address.city} -> Store City in Prestashop 1.7 
{$shop.address.state} -> Province of the store in Prestashop 1.7 
{$shop..address.country} -> Shop Country in Prestashop 1.7 
{$shop.phone} -> Store phone in Prestashop 1.7 
{$shop.fax} -> Store Fax in Prestashop 1.7

{$language.name} -> Language name enabled 
{$language.iso_code} -> ISO language code enabled 
{$language.language_code} -> Language code enabled (for Spanish, fr for French, tc ..) 
{$language.is_rtl} -> (1 -> On / 0 Off (for when language is written from right to left) 
{$language.format_lite} and {$ language.format_full} -> Simulated date format and full date format 
{$language.id} -> Language ID enabled

{$customer.lastname} -> Customer Last Name in Prestashop 1.7
{$customer.firstname} -> Client Name Prestashop 1.7
{$customer.email} -> Prestashop Customer Email 1.7
{$customer.birthday} -> Prestashop client birthday 1.7
{$customer.newsletter} -> Subscribed to the newsletter in Prestashop 1.7 (1 subscribed / 0 unsubscribed)
{$customer.newsletter_date_add} -> Newsletter subscription date
{$customer.ip_registration_newsletter} -> IP Registration Customers newsletter
{$customer.optin} -> Subscribed to offers from our partners in Prestashop 1.7 
{$customer.date_add} -> Client creation date in Prestashop 1.7
{$customer.date_upd} -> Last updated client update in Prestashop 1.7
{$customer.id} -> Customer ID in Prestashop 1.7
{$customer.id_default_group} -> Default group to which the client is associated in Prestashop 1.7
{$customer.is_logged } -> Check if the client is «logged in» in Prestashop 1.7
{$customer.gender.name [$ customer.gender.id]} -> Client Gender (Mr / Ms)
{$customer.addresses [Address ID] .city} -> Client city of address ‘X’ that has partner. (Address ID, because a client can theoretically have multiple addresses)
{$customer.addresses [Address ID] .alias} -> Address alias
{$customer.addresses [Address ID] .firstname} -> Addressholder last name
{$customer.addresses [Address ID] .lastname} -> Name of address holder
{$customer.addresses [Address ID] .company} -> Company name of address holder
{$customer.addresses [Address ID] .address1} -> Address 1
{$customer.addresses [Address ID] .address2} -> Address 2
{$customer.addresses [Address ID] .postcode} -> Mailing address
{$customer.addresses [Address ID] .id_state} -> Address Province ID
{$customer.addresses [Address ID] .state} -> Province address
{$customer.addresses [Address ID] .state_iso} -> ISO address province code
{$customer.addresses [Address ID] .id_country} -> Country address ID
{$customer.addresses [Address ID] .country} -> Country of address
{$customer.addresses [Address ID] .country_iso} -> ISO country address code
{$customer.addresses [Address ID] .phone} -> Address phone
{$customer.addresses [Address ID] .phone_mobile} -> Mobile phone address
{$customer.addresses [ID Address] .dni} -> Address ID
{$customer.addresses [Address ID] .vat_number} -> Customer VAT number
{$customer.addresses [Address ID] .formatted} -> Client formatted address

{$urls.base_url} -> Store address 
{$urls.current_url} -> Current address (url) where we are 
{$urls.shop_domain_url} -> Store domain 
{$urls.img_ps_url} -> Image root directory url 
{$urls.img_cat_url} -> Url directory of images of the categories 
{$urls.img_lang_url} -> Url of the language images directory 
{$urls.img_prod_url} -> Url of the product images directory 
{$urls.img_manu_url} -> Url directory of manufacturers images 
{$urls.img_sup_url} -> Url of the providers directory 
{$urls.img_ship_url} -> Url directory of images of carriers 
{$urls.img_store_url} 
{$urls.img_url} -> Url of the image directory of the template 
{$urls.css_url} -> Template URL directory url 
{$urls.js_url} -> Template JS directory url 
{$urls.pic_url} -> Url file directory uploaded 
{$urls.pages.address} -> Url from the «My Address» section 
{$urls.pages.addresses} -> Url from the «My addresses» section 
{$urls.pages.authentication} -> Url section of the authentication page 
{$urls.pages.cart} -> Cart section url (order summary) 
{$urls.pages.category} -> Url section of categories 
{$urls.pages.cms} -> Url of the content section 
{$urls.pages.contact} – > Url section of the contact form 
{$urls.pages.discount} -> Url of the discount voucher section 
{$urls.pages.guest_tracking} -> Tracking url for unregistered clients 
{$urls.pages.history} -> Url from the order history section 
{$urls.pages.identity} -> Url of the section «Personal data» 
{$urls.pages.index} -> Page url 
{$urls.pages.my_account} -> Url section of my account 
{$urls.pages.order_confirmation} -> Url section of the order confirmation page. 
{$urls.pages.order_follow} – > Url in the «Order Tracking» 
{$urls.pages.order} 
{$urls.pages.order_return} 
{$urls.pages.order_slip} 
{$urls.pages.pagenotfound} -> Url of section «404 (Page not found)» 
{$urls.pages.password} -> Url of the section «Recover Password» 
{$urls.pages.pdf_invoice} -> 
{$urls.pages.pdf_order_return} 
{$urls.pages.pdf_order_slip} 
{$urls.pages.prices_drop} -> Url section we lowered prices / products discount / discounts 
{$urls.pages.product} -> Product tab url 
{$urls.pages.search} -> Url of the searcher section 
{$urls.pages.sitemap} -> Site Map section url 
{$urls.pages.stores} -> Url of the section «Shops / Our stores» 
{$urls.pages.supplier} -> Url from the providers section 
{$urls.pages.register} -> Url log page 
{$urls.pages.order_login} 
{$urls.theme_assets} -> Url of the «assets» directory of the template / themes / template / assets / 
{$urls.actions.logout} -> Url to close section in the store

{if $page.page_name==’product’ OR $page.page_name==’cart’}