我编辑了inline.phtml,以便显示一个复选框选项,让访问者选择是否需要礼品包装。
<?php case 'onepage_checkout': ?>
<div class="gift-messages">
<h3><?php echo $this->__('Do you have any gift items in your order?'); ?></h3>
<p class="control">
<input type="checkbox" name="allow_gift_messages" id="allow_gift_messages" value="1" class="checkbox" />
<label for="allow_gift_messages"><?php echo $this->__('Add gift options.') ?></label>
</p>
</div>
这很有效。
但选中该复选框后,我想通过评论更新后端订单的历史记录(&#39;使用礼品包装&#39;)。
我应该在这里使用addstatushistorycomment()函数吗?
答案 0 :(得分:1)
最简单的方法是在inline.phtml页面中编辑javascript。
选中此复选框后,会显示一条消息&#39;带礼品包装&#39;在字段的textearea中添加了“gift-message-whole-message&#39;”。 如果未选中该复选框,则textarea中不会显示任何消息。 此外,包含textarea(&#39; allow-gift-messages-for-order-container&#39;)的div被CSS(display:none)隐藏,以便用户不会看到。
有关信息,在inline.phtml中编辑的javascript:
if(!window.toogleVisibilityOnObjects) {
var toogleVisibilityOnObjects = function(source, objects) {
var message = document.getElementById('gift-message-whole-message');
if($(source) && $(source).checked) {
message.value = "With a gift packaging"
objects.each(function(item){
$(item).show();
$$('#' + item + ' .input-text').each(function(item) {
item.removeClassName('validation-passed');
});
});
} else {
message.value = "";
objects.each(function(item){
if ($(item)) {
$(item).hide();
$$('#' + item + ' .input-text').each(function(sitem) {
sitem.addClassName('validation-passed');
});
$$('#' + item + ' .giftmessage-area').each(function(sitem) {
sitem.value = '';
});
$$('#' + item + ' .checkbox').each(function(sitem) {
sitem.checked = false;
});
$$('#' + item + ' .select').each(function(sitem) {
sitem.value = '';
});
$$('#' + item + ' .price-box').each(function(sitem) {
sitem.addClassName('no-display');
});
}
});
}
}
}