0

我需要在我的信用卡支付模块中添加一个包裹选择。据我了解,将信息发送给信用卡公司的文件也包含卡号:

$payment_cc_number      = $payment->getCcNumber();

在同一个文件中,有一行包含包裹的数量......

$payment_parcels        = $this->getConfigData('parcel_number');

...但他们没有被抓获。在模块中,我使用了一个简单的标记:

        <select id="" name="parcels" class="required-entry">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
        </select>

如何发送客户选择的值?

4

1 回答 1

0

您应该在和表中创建cc_parcels字段,并将下面的代码添加到模块的适当位置。sales_flat_order_paymentsales_flat_quote_payment

块信息类:

<?php
class Company_Module_Block_Info extends Mage_Payment_Block_Info_Cc {
    protected function _prepareSpecificInformation($transport = null) {
        $transport = parent::_prepareSpecificInformation($transport);
        if ($this->getInfo()->getCcParcels()) {
            $transport[$this->__('Parcels')] = $this->getInfo()->getCcParcels();
        }
        return $transport;
    }
}

方法类:

<?php
class Company_Module_Model_Method extends Mage_Payment_Model_Method_Cc {
    public function assignData($data) {
        $this->getInfoInstance()->setCcParcels($data['cc_parcels']);
    }
}

配置.xml:

<?xml version="1.0"?>
<config>
    <global>
        <fieldsets>
            <sales_convert_quote_payment>
                <cc_parcels><to_order_payment>*</to_order_payment></cc_parcels>
            </sales_convert_quote_payment>
            <sales_convert_order_payment>
                <cc_parcels><to_quote_payment>*</to_quote_payment></cc_parcels>
            </sales_convert_order_payment>
        </fieldsets>
    </global>
</config>

表单.phtml:

<label for="<?php echo $_code ?>_cc_parcels"><?php echo $this->__('Parcels') ?></label>
<div class="input-box">
    <select id="<?php echo $_code ?>_cc_parcels" name="payment[cc_parcels]">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
    </select>
</div>

要获得包裹编号,您必须像$order->getPayment()->getCcParcels()(也来自$quote)一样获得它。

于 2013-07-25T01:37:43.097 回答