4
這是從文件「select.phtml」的代碼:app/design/frontend/base/default/template/bundle/catalog/product /view/type/bundle/option/select.phtmlMagento 1.7.0.2:在下拉式捆綁產品選項中顯示默認數量
什麼代碼做我需要插入,這樣我可以顯示默認的數量在下拉列表中的產品名稱旁邊的捆綁產品選項
或者至少我如何獲得基於產品ID的選項的默認數量?
<?php $_option = $this->getOption(); ?>
<?php $_selections = $_option->getSelections(); ?>
<?php $_default = $_option->getDefaultSelection(); ?>
<?php list($_defaultQty, $_canChangeQty) = $this->_getDefaultValues(); ?>
<dt>
<label<?php if ($_option->getRequired()) echo ' class="required"' ?>><?php echo $this->htmlEscape($_option->getTitle()) ?><?php if ($_option->getRequired()) echo '<em>*</em>' ?></label>
</dt>
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<?php if ($this->_showSingle()): ?>
<?php echo $this->getSelectionTitlePrice($_selections[0]) ?>
<input type="hidden" name="bundle_option[<?php echo $_option->getId() ?>]" value="<?php echo $_selections[0]->getSelectionId() ?>"/>
<?php else:?>
<select onchange="bundle.changeSelection(this)" id="bundle-option-<?php echo $_option->getId() ?>" name="bundle_option[<?php echo $_option->getId() ?>]" class="bundle-option-<?php echo $_option->getId() ?><?php if ($_option->getRequired()) echo ' required-entry' ?> bundle-option-select change-container-classname">
<option value=""><?php echo $this->__('Choose a selection...') ?></option>
<?php foreach ($_selections as $_selection): ?>
<option value="<?php echo $_selection->getSelectionId() ?>"<?php if ($this->_isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>><?php echo $this->getSelectionTitlePrice($_selection, false) ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
<span class="qty-holder" style="display: inline-block; margin-left: 20px;">
<label for="bundle-option-<?php echo $_option->getId() ?>-qty-input"><?php echo $this->__('Qty:') ?> </label><input onkeyup="bundle.changeOptionQty(this, event)" onblur="bundle.changeOptionQty(this, event)" <?php if (!$_canChangeQty) echo ' disabled="disabled"' ?> id="bundle-option-<?php echo $_option->getId() ?>-qty-input" class="input-text qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>" type="text" name="bundle_option_qty[<?php echo $_option->getId() ?>]" value="<?php echo $_defaultQty ?>" style="background-color: rgb(248, 248, 248);"/>
</span>
</div>
</dd>
它的工作原理!非常感謝monojit,這正是我想要的。我非常感謝你的輸入:) – RaduS
謝謝你。感覺很高興幫助你。 :) – monojit
我知道這是脫離主題,但你知道我怎麼能在同一個循環中獲得選定選項的原始產品ID?我可以通過使用這個'<?php echo $ _selection-> getSelectionId()?>'來獲得ID,但這不是所選產品的原始ID。你有什麼想法或建議,我怎麼能得到它? – RaduS