我正在使用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:我知道编辑基本文件,我这样做然后复制到我的文件夹。