Question

La zone de saisie de la quantité est absente des pages de produits simples.Lorsque j'active les indications de modèle, je vois beaucoup plus de blocs dans le produit de configuration que dans le produit simple.

Par exemple, j'obtiens les blocs suivants dans la configuration (qui contiennent la quantité de produit).

frontend/default/site/template/catalog/product/view/options/wrapper.phtml
frontend/default/site/template/catalog/product/view/type/options/configurable.phtml
frontend/base/default/template/catalog/product/view/options/js.phtml
frontend/default/site/template/catalog/product/view/options.phtml
frontend/default/site/template/page/js/calendar.phtml

Mais en simple, je ne vois aucun de ces blocs affichés dans des astuces basées sur un modèle.

Je ne pense pas que ce soit un problème avec XML car j'ai testé le catalog.xml de base et toujours la même boîte de quantité manquante.Toute idée serait très utile.Merci d'avance.

Au départ, je pensais que c'était quelque chose dans le fichier options.phtml, mais encore une fois, je ne suis pas sûr.

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
/* @var $this Mage_Catalog_Block_Product_View_Options */
?>

<?php $_options = Mage::helper('core')->decorateArray($this->getOptions()) ?>
<?php if (count($_options)):?>
    <script type="text/javascript">
    //<![CDATA[
    var optionFileUpload = {
        productForm : $('product_addtocart_form'),
        formAction : '',
        formElements : {},
        upload : function(element){
            this.formElements = this.productForm.select('input', 'select', 'textarea', 'button');
            this.removeRequire(element.readAttribute('id').sub('option_', ''));

            template = '<iframe id="upload_target" name="upload_target" style="width:0; height:0; border:0;"><\/iframe>';

            Element.insert($('option_'+element.readAttribute('id').sub('option_', '')+'_uploaded_file'), {after: template});

            this.formAction = this.productForm.action;

            var baseUrl = '<?php echo $this->getUrl('*/product/upload') ?>';
            var urlExt = 'option_id/'+element.readAttribute('id').sub('option_', '');

            this.productForm.action = parseSidUrl(baseUrl, urlExt);
            this.productForm.target = 'upload_target';
            this.productForm.submit();
            this.productForm.target = '';
            this.productForm.action = this.formAction;
        },
        removeRequire : function(skipElementId){
            for(var i=0; i<this.formElements.length; i++){
                if (this.formElements[i].readAttribute('id') != 'option_'+skipElementId+'_file' && this.formElements[i].type != 'button') {
                    this.formElements[i].disabled='disabled';
                }
            }
        },
        addRequire : function(skipElementId){
            for(var i=0; i<this.formElements.length; i++){
                if (this.formElements[i].readAttribute('name') != 'options_'+skipElementId+'_file' && this.formElements[i].type != 'button') {
                    this.formElements[i].disabled='';
                }
            }
        },
        uploadCallback : function(data){
            this.addRequire(data.optionId);
            $('upload_target').remove();

            if (data.error) {

            } else {
                $('option_'+data.optionId+'_uploaded_file').value = data.fileName;
                $('option_'+data.optionId+'_file').value = '';
                $('option_'+data.optionId+'_file').hide();
                $('option_'+data.optionId+'').hide();
                template = '<div id="option_'+data.optionId+'_file_box"><a href="#"><img src="var/options/'+data.fileName+'" alt=""><\/a><a href="#" onclick="optionFileUpload.removeFile('+data.optionId+')" title="Remove file" \/>Remove file<\/a>';

                Element.insert($('option_'+data.optionId+'_uploaded_file'), {after: template});
            }
        },
        removeFile : function(optionId)
        {
            $('option_'+optionId+'_uploaded_file').value= '';
            $('option_'+optionId+'_file').show();
            $('option_'+optionId+'').show();

            $('option_'+optionId+'_file_box').remove();
        }
    }
    var optionTextCounter = {
        count : function(field,cntfield,maxlimit){
            if (field.value.length > maxlimit){
                field.value = field.value.substring(0, maxlimit);
            } else {
                cntfield.innerHTML = maxlimit - field.value.length;
            }
        }
    }

    Product.Options = Class.create();
    Product.Options.prototype = {
        initialize : function(config) {
            this.config = config;
            this.reloadPrice();
            document.observe("dom:loaded", this.reloadPrice.bind(this));
        },
        reloadPrice : function() {
            var config = this.config;
            var skipIds = [];
            $$('body .product-custom-option').each(function(element){
                var optionId = 0;
                element.name.sub(/[0-9]+/, function(match){
                    optionId = parseInt(match[0], 10);
                });
                if (config[optionId]) {
                    var configOptions = config[optionId];
                    var curConfig = {price: 0};
                    if (element.type == 'checkbox' || element.type == 'radio') {
                        if (element.checked) {
                            if (typeof configOptions[element.getValue()] != 'undefined') {
                                curConfig = configOptions[element.getValue()];
                            }
                        }
                    } else if(element.hasClassName('datetime-picker') && !skipIds.include(optionId)) {
                        dateSelected = true;
                        $$('.product-custom-option[id^="options_' + optionId + '"]').each(function(dt){
                            if (dt.getValue() == '') {
                                dateSelected = false;
                            }
                        });
                        if (dateSelected) {
                            curConfig = configOptions;
                            skipIds[optionId] = optionId;
                        }
                    } else if(element.type == 'select-one' || element.type == 'select-multiple') {
                        if ('options' in element) {
                            $A(element.options).each(function(selectOption){
                                if ('selected' in selectOption && selectOption.selected) {
                                    if (typeof(configOptions[selectOption.value]) != 'undefined') {
                                        curConfig = configOptions[selectOption.value];
                                    }
                                }
                            });
                        }
                    } else {
                        if (element.getValue().strip() != '') {
                            curConfig = configOptions;
                        }
                    }
                    if(element.type == 'select-multiple' && ('options' in element)) {
                        $A(element.options).each(function(selectOption) {
                            if (('selected' in selectOption) && typeof(configOptions[selectOption.value]) != 'undefined') {
                                if (selectOption.selected) {
                                    curConfig = configOptions[selectOption.value];
                                } else {
                                    curConfig = {price: 0};
                                }
                                optionsPrice.addCustomPrices(optionId + '-' + selectOption.value, curConfig);
                                optionsPrice.reload();
                            }
                        });
                    } else {
                        // optionsPrice.addCustomPrices(element.id || optionId, curConfig);
                        optionsPrice.reload();
                    }
                }
            });
        }
    }
    function validateOptionsCallback(elmId, result) {
        var container = $(elmId).up('ul.options-list');
        if (result == 'failed') {
            container.removeClassName('validation-passed');
            container.addClassName('validation-failed');
        } else {
            container.removeClassName('validation-failed');
            container.addClassName('validation-passed');
        }
    }
    var opConfig = new Product.Options(<?php echo $this->getJsonConfig() ?>);
    //]]>
    </script>
    <?php $i = 0; ?>
    <?php $_product = Mage::getBlockSingleton('catalog/product_view')->getProduct(); ?>
    <?php if($_product->getTypeId() == 'simple'){ ?>
        <div class="custom-options-info">
        <!--**************Custom option*************-->
            <?php $heightDecimal = explode(',',$_product->getHeightDecimal()); ?>
            <?php $widthDecimal = explode(',',$_product->getWidthDecimal()); ?>
                <div class="combination-widtth-height">
                    <?php foreach ($_product->getOptions() as $valueCustom) { ?> 
                          <?php if($valueCustom->getTitle() == 'Height'){ ?>
                            <div class="height-option">
                            <label<?php if ($valueCustom->getIsRequire()) echo ' class="required"' ?>><?php if ($valueCustom->getIsRequire()) echo '<em>*</em>' ?><?php echo  $this->htmlEscape($valueCustom->getTitle()) ?></label>    
                                    <input id="put-value-height" onkeyup="putValueHeight('options_<?php echo $valueCustom->getId() ?>_text',this.value)"  type="text"  class="input-text<?php echo $valueCustom->getIsRequire() ? ' required-entry' : '' ?> <?php echo $valueCustom->getMaxCharacters() ? ' validate-length maximum-length-'.$valueCustom->getMaxCharacters() : '' ?> product-custom-option" value="<?php echo $this->escapeHtml($this->getDefaultValue()) ?>" />
                                    <select class="input-text product-custom-option" id="put-value-height-decimal" onchange="putValueHeightDecimal('options_<?php echo $valueCustom->getId() ?>_text',this.value)">
                                        <option value="">0</option>  
                                        <?php foreach($heightDecimal as $hgtDec): ?>
                                            <?php $heightDecimalText = explode('/',$hgtDec); ?>
                                            <?php $heightDecimalInt1 = $heightDecimalText[0]; ?>
                                            <?php $heightDecimalInt2 = $heightDecimalText[1]; ?>
                                        <option value="<?php echo number_format(round(($heightDecimalInt1 / $heightDecimalInt2),3),3); ?>"><?php echo $hgtDec; ?></option>    
                                        <?php endforeach; ?>
                                    </select>
                                    </div>
                                <?php }

                                if($valueCustom->getTitle() == 'Width'){ ?>
                                    <div class="width-option">
                                    <label<?php if ($valueCustom->getIsRequire()) echo ' class="required"' ?>><?php if ($valueCustom->getIsRequire()) echo '<em>*</em>' ?><?php echo  $this->htmlEscape($valueCustom->getTitle()) ?></label>    
                                    <input id="put-value-width" onkeyup="putValueWidth('options_<?php echo $valueCustom->getId() ?>_text',this.value)"  type="text"  class="input-text<?php echo $valueCustom->getIsRequire() ? ' required-entry' : '' ?> <?php echo $valueCustom->getMaxCharacters() ? ' validate-length maximum-length-'.$valueCustom->getMaxCharacters() : '' ?> product-custom-option" value="<?php echo $this->escapeHtml($this->getDefaultValue()) ?>" />
                                    <select class="input-text product-custom-option" id="put-value-width-decimal" onchange="putValueWidthDecimal('options_<?php echo $valueCustom->getId() ?>_text',this.value)">
                                        <option value="">0</option>  
                                        <?php foreach($widthDecimal as $hgtDec): ?>
                                            <?php $heightDecimalText = explode('/',$hgtDec); ?>
                                            <?php $heightDecimalInt1 = $heightDecimalText[0]; ?>
                                            <?php $heightDecimalInt2 = $heightDecimalText[1]; ?>
                                        <option value="<?php echo number_format(round(($heightDecimalInt1 / $heightDecimalInt2),3),3); ?>"><?php echo $hgtDec; ?></option>    
                                        <?php endforeach; ?>
                                    </select>
                                    </div>
                                <?php } ?>

                                <?php } ?>
                          </div>
                            <!--**************Custom option*************-->
    <?php foreach($_options as $_option): ?>
        <?php  
            if($i > 1 && $i % 3 == 2){
//                echo '<div class="custom-options-info">';  ?>

            <?php }
//            if($i == 0){
//                echo '<div class="custom-options-first-info">';
//            }
        ?>
        <?php echo $this->getOptionHtml($_option) ?>
        <?php 
//            if($i > 1 && $i % 3 == 1){
//                echo '</div>';
//            }
//            if($i == 1){
//                echo '</div>';
//            }
            ?>
    <?php $i++; ?>
    <?php endforeach; ?>
        <?php 
//        if($i % 3 != 2){
//             echo '</div>';
//        } 
//        if($i == 1){
//             echo '</div>';
//        } 
        ?>
                            <?php if ($_product->isSaleable()): ?>
        <?php if (!$_product->isGrouped()): ?>
        <?php $prodminqty = $_product->getStockItem()->getMinSaleQty(); ?>
            <div class="prod_quantity">
                <label for="qty"><?php echo $this->__('Quantity') ?></label>
                <input type="text" name="qty" id="qty"  value="<?php echo $prodminqty > 0 ? $prodminqty : 1; ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
            </div>
                        <?php $edge_image = $_product->getEdgeImage() ?>
                <?php if ($_product->getEdgeType() == 1): ?>
                    <div class="edge-link">
                        <a id="edge-box-a"><?php echo $this->__('Outside Edge Image Options'); ?></a>
                    </div>
            <div id='edge-image-none' style='display:none'><img src="<?php echo Mage::getBaseUrl('media') . 'edge_image/' . $edge_image ?>"/></div>
            <div id="edge-image-parent" class='egde-image-class-parent'>
                    <div class="fancybox-item" id="edge-image" style='display:none'>
                            <img src="<?php echo Mage::getBaseUrl('media') . 'edge_image/' . $edge_image ?>"/>
                    </div>
            </div>
        <?php endif; ?>
                    <script type="text/javascript">
                    jQuery(document).ready(function() {
                        jQuery("a#edge-box-a").fancybox({
                            'width': '100%',
                            'height': '100%',
                            'autoScale': true,
                            'transitionIn': 'fade',
                            'transitionOut': 'fade',
                            'type': 'inline',
                            'href': '#edge-image',
                            afterClose: function() {
                                 htmlstart="  <div id='edge-image' class='fancybox-item' style='display:none;'>";
                                 htmlEnd="</div>";
                                jQuery("#edge-image-parent").html(htmlstart+jQuery("#edge-image-none").html()+htmlEnd);
                            }
                        });

                    });
                    </script>

    <?php endif; ?>
        <?php endif; ?>
                            </div>
    <?php }else{ ?>
    <?php foreach($_options as $_option): ?>
        <?php  
            if($i == 0 && strtolower($_option->getTitle()) != 'width' && strtolower($_option->getTitle()) != 'height'){
                echo '<div class="custom-options-info">';
            }
            if($i > 1 && $i % 3 == 2 && strtolower($_option->getTitle()) != 'width' && strtolower($_option->getTitle()) != 'height'){
                echo '<div class="custom-options-info custom-options-info-new">';
            }
//            elseif($i != 0 && $i % 3 == 1){
//                echo '<div class="custom-options-info-new">';
//            }
        ?>
        <?php echo $this->getOptionHtml($_option) ?>
        <?php 
            if($i == 1 && strtolower($_option->getTitle()) != 'width' && strtolower($_option->getTitle()) != 'height'){
                echo '</div>';
            }
            if($i > 1 && $i % 3 == 1 && strtolower($_option->getTitle()) != 'width' && strtolower($_option->getTitle()) != 'height'){
                echo '</div>';
            }

            ?>
    <?php 
    if(strtolower($_option->getTitle()) != 'width' && strtolower($_option->getTitle()) != 'height'){
    $i++;
    } ?>
    <?php endforeach; ?>
     <?php if($i % 3 != 1){
             echo '</div>';
        } ?>
    <?php } ?>

<?php endif; ?>

<?php // Quantity box for config products ?>
<?php $_product = Mage::getBlockSingleton('catalog/product_view')->getProduct(); ?>
    <?php if($_product->getTypeId() == 'configurable'){ ?>
            <div class="prod_quantity">
                <label for="qty"><?php echo $this->__('Quantity') ?></label>
                <input type="text" name="qty" id="qty"  value="<?php echo $prodminqty > 0 ? $prodminqty : 1; ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
            </div>
<?php } ?>
Était-ce utile?

La solution

Pour un produit simple, le champ QTY se trouve généralement dans le fichier addtocart.phtml qui est extrait dans le fichier view.phtml avec l'appel <?php echo $this->getChildHtml('addtocart') ?> Je vous recommande de vérifier si vous avez le $this->getChildHtml('addtocart') appelez votre thème view.phtml et vérifiez également votre fichier de thèmes addotcart.phtml par rapport à ce qui se trouve dans base/default.

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top