Esta página fue impresa el Mar 25, 2023. Para acceder a la versión actual, por favor visita https://help.shopify.com/es/manual/online-store/themes/themes-by-shopify/vintage-themes/customizing-vintage-themes/add-pick-an-option.
Cuando un cliente visita una página de producto en tu tienda online, se selecciona la primera variante disponible de forma predeterminada. Puedes usar esta personalización para desactivar la selección automática de la primera variante disponible. De esta manera, antes de mostrar una variante, se le solicitará al cliente que seleccione una manualmente.
En la sección Canales de ventas, selecciona Tienda online.
Toca Administrar temas.
Busca el tema que deseas editar, haz clic en el botón ... para abrir el menú de acciones y luego haz clic en Editar código.
En el directorio Componentes, haz clic en theme.js o theme.js.liquid.
Encuentra el código initVariantSelectors. Debajo, se encuentra el siguiente código:
// Clean up variant labels if the Shopify-defined// defaults are the only ones leftthis.simplifyVariantLabels(this.productSingleObject,this.$container);
Add the following code on a new line below:
if (typeof(productOptions)!="undefined"){for (i=0;i<productOptions.length;i++){constvowels=['a','e','i','o','u'];constfirstOptionLetter=productOptions[i][i][0].toLowerCase();letindef='a';if (vowels.includes(firstOptionLetter)){indef='an';};constselect=document.querySelectorAll('.single-option-selector')[i];constoptions=select.querySelectorAll('option');if (options.length>1){letoption=newOption('Pick '+indef+''+productOptions[i][i],'');select.add(option,select.firstChild);select.selectedIndex=0;}}}
It should look something like this:
// Clean up variant labels if the Shopify-defined// defaults are the only ones leftthis.simplifyVariantLabels(this.productSingleObject,this.$container);if (typeof(productOptions)!="undefined"){for (i=0;i<productOptions.length;i++){constvowels=['a','e','i','o','u'];constfirstOptionLetter=productOptions[i][i][0].toLowerCase();letindef='a';if (vowels.includes(firstOptionLetter)){indef='an';};constselect=document.querySelectorAll('.single-option-selector')[i];constoptions=select.querySelectorAll('option');if (options.length>1){letoption=newOption('Pick '+indef+''+productOptions[i][i],'');select.add(option,select.firstChild);select.selectedIndex=0;}}}
There are *two instances* of this line of code, both found within the `productVariantCallback` function. Replace only the *second* instance with:
$(selectors.addToCartText).html('Make a Selection');
> Note:
> Some versions of Boundless do not include the line of code to be replaced in this step. If you can't find the code, then skip to the next step.
Haz clic en Guardar.
Editar la plantilla de tu página de producto
Para editar la plantilla de tu página de producto:
En el directorio Secciones, haz clic en product-template.liquid.
Cambiar la configuración de idioma del botón Agregar al carrito
Puedes cambiar la configuración del idioma para el botón Agregar al carrito para que los productos no aparezcan como "No disponible" antes de realizar una selección.
Busca el código _updatePrice: function(variant). Reemplaza el siguiente código:
if (variant.price===this.currentVariant.price&&variant.compare_at_price===this.currentVariant.compare_at_price&&variant.unit_price===this.currentVariant.unit_price){return;}
> Note:
> Some versions of Debut do not include the code to be replaced in this step. If you can't find the code, then skip to the next step.
Cambiar la configuración de idioma del botón Agregar al carrito
Puedes cambiar la configuración del idioma para el botón Agregar al carrito para que los productos no aparezcan como "No disponible" antes de realizar una selección.
En la sección Canales de ventas, selecciona Tienda online.
Toca Administrar temas.
Busca el tema que deseas editar, haz clic en el botón ... para abrir el menú de acciones y luego haz clic en Editar código.
En el directorio Componentes, haz clic en theme.js o theme.js.liquid.
Encuentra el código initProductVariant: function() {. Debajo, se encuentra el siguiente código:
// Hide selectors if we only have 1 variant and its title contains 'Default'.if (product.variants.length===1&&product.variants[0].title.toLowerCase().indexOf('default')!==-1){$('.selector-wrapper',this.$container).hide();}
Add the following code on a new line below:
if (typeof(productOptions)!="undefined"){for (i=0;i<productOptions.length;i++){constvowels=['a','e','i','o','u'];constfirstOptionLetter=productOptions[i][i][0].toLowerCase();letindef='a';if (vowels.includes(firstOptionLetter)){indef='an';};constselect=document.querySelectorAll('.single-option-selector')[i];constoptions=select.querySelectorAll('option');if (options.length>1){letoption=newOption('Pick '+indef+''+productOptions[i][i],'');select.add(option,select.firstChild);select.selectedIndex=0;}}}
It should look something like this:
// Hide selectors if we only have 1 variant and its title contains 'Default'.if (product.variants.length===1&&product.variants[0].title.toLowerCase().indexOf('default')!==-1){$('.selector-wrapper',this.$container).hide();}if (typeof(productOptions)!="undefined"){for (i=0;i<productOptions.length;i++){constvowels=['a','e','i','o','u'];constfirstOptionLetter=productOptions[i][i][0].toLowerCase();letindef='a';if (vowels.includes(firstOptionLetter)){indef='an';};constselect=document.querySelectorAll('.single-option-selector')[i];constoptions=select.querySelectorAll('option');if (options.length>1){letoption=newOption('Pick '+indef+''+productOptions[i][i],'');select.add(option,select.firstChild);select.selectedIndex=0;}}}
Haz clic en Guardar.
Edita la plantilla de tu página de producto:
Para editar la plantilla de tu página de producto:
En el directorio Secciones, haz clic en product-template.liquid.
Cambiar la configuración de idioma del botón Agregar al carrito
Puedes cambiar la configuración del idioma para el botón Agregar al carrito para que los productos no aparezcan como "No disponible" antes de realizar una selección.
Cambiar la configuración de idioma del botón Agregar al carrito
Puedes cambiar la configuración del idioma para el botón Agregar al carrito para que los productos no aparezcan como "No disponible" antes de realizar una selección.
En la sección Canales de ventas, selecciona Tienda online.
Toca Administrar temas.
Busca el tema que deseas editar, haz clic en el botón ... para abrir el menú de acciones y luego haz clic en Editar código.
En el directorio Componentes, haz clic en theme.js o theme.js.liquid.
Encuentra el código initProductVariant: function() {. Debajo, se encuentra el siguiente código:
// Clean up variant labels if the Shopify-defined// defaults are the only ones leftSlate.simplifyVariantLabels(this.productSingleObject,this.$container);
Add the following code on a new line below:
if (typeof(productOptions)!="undefined"){for (i=0;i<productOptions.length;i++){constvowels=['a','e','i','o','u'];constfirstOptionLetter=productOptions[i][i][0].toLowerCase();letindef='a';if (vowels.includes(firstOptionLetter)){indef='an';};constselect=document.querySelectorAll('.single-option-selector')[i];constoptions=select.querySelectorAll('option');if (options.length>1){letoption=newOption('Pick '+indef+''+productOptions[i][i],'');select.add(option,select.firstChild);select.selectedIndex=0;}}}
It should look something like this:
// Clean up variant labels if the Shopify-defined// defaults are the only ones leftSlate.simplifyVariantLabels(this.productSingleObject,this.$container);if (typeof(productOptions)!="undefined"){for (i=0;i<productOptions.length;i++){constvowels=['a','e','i','o','u'];constfirstOptionLetter=productOptions[i][i][0].toLowerCase();letindef='a';if (vowels.includes(firstOptionLetter)){indef='an';};constselect=document.querySelectorAll('.single-option-selector')[i];constoptions=select.querySelectorAll('option');if (options.length>1){letoption=newOption('Pick '+indef+''+productOptions[i][i],'');select.add(option,select.firstChild);select.selectedIndex=0;}}}
Haz clic en Guardar.
Editar la plantilla de tu página de producto
Para editar la plantilla de tu página de producto:
En el directorio Secciones, haz clic en product-template.liquid.
Cambiar la configuración de idioma del botón Agregar al carrito
Puedes cambiar la configuración del idioma para el botón Agregar al carrito para que los productos no aparezcan como "No disponible" antes de realizar una selección.
En la sección Canales de ventas, selecciona Tienda online.
Toca Administrar temas.
Busca el tema que deseas editar, haz clic en el botón ... para abrir el menú de acciones y luego haz clic en Editar código.
En el directorio Componentes, haz clic en theme.js o theme.js.liquid.
Encuentra el código initProductVariant: function() {. Debajo, se encuentra el siguiente código:
// Clean up variant labels if the Shopify-defined// defaults are the only ones leftthis.simplifyVariantLabels(this.productSingleObject);
Add the following code on a new line below:
if (typeof(productOptions)!="undefined"){for (i=0;i<productOptions.length;i++){constvowels=['a','e','i','o','u'];constfirstOptionLetter=productOptions[i][i][0].toLowerCase();letindef='a';if (vowels.includes(firstOptionLetter)){indef='an';};constselect=document.querySelectorAll('.single-option-selector')[i];constoptions=select.querySelectorAll('option');if (options.length>1){letoption=newOption('Pick '+indef+''+productOptions[i][i],'');select.add(option,select.firstChild);select.selectedIndex=0;}}}
It should look something like this:
// Clean up variant labels if the Shopify-defined// defaults are the only ones leftthis.simplifyVariantLabels(this.productSingleObject);if (typeof(productOptions)!="undefined"){for (i=0;i<productOptions.length;i++){constvowels=['a','e','i','o','u'];constfirstOptionLetter=productOptions[i][i][0].toLowerCase();letindef='a';if (vowels.includes(firstOptionLetter)){indef='an';};constselect=document.querySelectorAll('.single-option-selector')[i];constoptions=select.querySelectorAll('option');if (options.length>1){letoption=newOption('Pick '+indef+''+productOptions[i][i],'');select.add(option,select.firstChild);select.selectedIndex=0;}}}
Haz clic en Guardar.
Editar la plantilla de tu página de producto
Para editar la plantilla de tu página de producto:
En el directorio Secciones, haz clic en product-template.liquid.
Cambiar la configuración de idioma del botón Agregar al carrito
Puedes cambiar la configuración del idioma para el botón Agregar al carrito para que los productos no aparezcan como "No disponible" antes de realizar una selección.
Cambiar la configuración de idioma del botón Agregar al carrito
Puedes cambiar la configuración del idioma para el botón Agregar al carrito para que los productos no aparezcan como "No disponible" antes de realizar una selección.
En el directorio Diseño, haz clic en theme.liquid.
Busca la etiqueta de cierre </body> cerca del final del archivo. En una nueva línea justo encima de la etiqueta de cierre </body>, pega el siguiente código:
{%render'pick-an-option'%}
Haz clic en Guardar.
Busca el archivo que contiene el formulario de agregar al carrito: Tendrá un atributo action establecido en /cart/add.
Cambiar la configuración de idioma del botón Agregar al carrito
Puedes cambiar la configuración del idioma para el botón Agregar al carrito para que los productos no aparezcan como "No disponible" antes de realizar una selección.