如果选中该复选框,请向后端发送消息


If the checkbox is checked, send a message to the backend

我编辑了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>

这是有效的。

但是当选中该复选框时,我想通过评论("带有礼品包装"(更新后端的订单历史记录。

我应该在这里使用 addstatushistorycomment(( 函数吗?

最简单的方法是在inline.phtml页面中编辑javascript。

选中该复选框后,将在"礼品-消息-整个消息"字段的文本区域中添加一条消息"带有礼品包装"。如果未选中该复选框,则文本区域中不显示任何消息。此外,包含文本区域('allow-gift-messages-for-order-container'(的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');
                });
            }
        });
    }
}

}