我在 Magento 网站http://mydolcessa.com上工作
我在结帐页面添加了一个复选框,确认他们授权公司从他们的信用卡中扣款并确认退货和退款政策。(如下所示)
在您看到订单的管理区域中,我添加了一行“授权收费:”当前,如果我在已设置的列中手动将值输入到数据库中,它将正确读取并显示在那里。
我需要帮助是将复选框插入是或否到数据库的列中。
app/design/frontend/base/default/template/payment/form/Ccsave.phtml 上的复选框代码
<li>
<div class="input-box">
<input type="checkbox" id="<?php echo $_code ?>_cc_checkbox"" name="payment[cc_checkbox]" title="<?php echo $this->__('By checking this box, I authorize this transaction and acknowledge the refund/exchange policy discussed in the "customer care" section of the website.') ?>" class="input-text validate-cc-checkbox validate-cc-type" value="Yes" />
<label for="<?php echo $_code ?>_cc_checkbox" class="required"><em>*</em><?php echo $this->__('By checking this box, I authorize this transaction and acknowledge the refund/exchange policy discussed in the "customer care" section of the website.') ?></label>
</div>
</li>
app/code/core/Mage/Payment/Block/Info/Cc.php 上的复选框代码
/**
* Retrieve Checkbox Status
*
* @return string
*/
public function getCcCheckbox()
{
$checkbox = Mage::getSingleton('payment/config')->getCcCheckbox();
$ccCheckbox = $this->getInfo()->getCcCheckbox();
if (isset($checkbox[$ccCheckbox])) {
return $checkbox[$ccCheckbox];
}
return (empty($ccCheckbox)) ? Mage::helper('payment')->__('No') : $ccCheckbox;
}
app/code/core/Mage/Payment/Block/Info/Ccsave.php 上的复选框代码(显示在后端)
class Mage_Payment_Block_Info_Ccsave extends Mage_Payment_Block_Info_Cc
{
/**
* Show name on card, expiration date and full cc number
*
* Expiration date and full number will show up only in secure mode (only for admin, not in emails or pdfs)
*
* @param Varien_Object|array $transport
*/
protected function _prepareSpecificInformation($transport = null)
{
if (null !== $this->_paymentSpecificInformation) {
return $this->_paymentSpecificInformation;
}
$info = $this->getInfo();
$transport = new Varien_Object(array(Mage::helper('payment')->__('Name on the Card') => $info->getCcOwner(),));
$transport = parent::_prepareSpecificInformation($transport);
if (!$this->getIsSecureMode()) {
$transport->addData(array(
Mage::helper('payment')->__('Expiration Date') => $this->_formatCardDate(
$info->getCcExpYear(), $this->getCcExpMonth()
),
Mage::helper('payment')->__('Credit Card Number') => $info->getCcNumber(),
Mage::helper('payment')->__('Authorized to Charge') => $info->getCcCheckbox(),
));
}
return $transport;
}
}
我应该把这样的代码放在哪里?
<?php $cc_checkbox = $_GET["cc_checkbox"];
require_once 'app/Mage.php';
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$writeConnection = $resource->getConnection('core_write');
$tableName = $resource->getTableName('sales_flat_order_payment');
if ($cc_checkbox == true) {
$checked="Yes";
$query = "UPDATE INTO {$tableName} (cc_checkbox)
VALUES ('Yes')";
}
else {
$checked="No";
$query = "INSERT INTO {$tableName} (cc_checkbox)
VALUES ('No')";
}
$writeConnection->query($query);
?>
PS:我知道编辑基本文件,我这样做然后复制到我的文件夹中。