所以,我开始对一些Magento代码进行破解。我试图追踪计算购物车页面上的运费的代码。我正在查看/your_theme/template/checkout/cart/
中名为shipping.phtml
的文件。Magento:跟踪和调试其PHP代码
邮政编码输入框:
<li>
<label for="postcode"<?php if ($this->isZipCodeRequired()) echo ' class="required"' ?>><?php if ($this->isZipCodeRequired()) echo '<em>*</em>' ?><?php echo $this->__('Zip/Postal Code') ?></label>
<input class="input-text validate-postcode<?php if ($this->isZipCodeRequired()):?> required-entry<?php endif;?>" type="text" id="postcode" name="estimate_postcode" value="<?php echo $this->htmlEscape($this->getEstimatePostcode()) ?>" />
</li>
计算运费按钮:
<div class="buttons-set">
<button type="button" onclick="coShippingMethodForm.submit()" class="button"><span><span><?php echo $this->__('Get a Quote') ?></span></span></button>
</div>
的Javascript:
<script type="text/javascript">
//<![CDATA[
var coShippingMethodForm = new VarienForm('shipping-zip-form');
var countriesWithOptionalZip = <?php echo $this->helper('directory')->getCountriesWithOptionalZip(true) ?>;
coShippingMethodForm.submit = function() {
var country = $F('country');
var optionalZip = false;
for (i=0; i < countriesWithOptionalZip.length; i++) {
if (countriesWithOptionalZip[i] == country) {
optionalZip = true;
}
}
if (optionalZip) {
$('postcode').removeClassName('required-entry');
}
else {
$('postcode').addClassName('required-entry');
}
return VarienForm.prototype.submit.bind(coShippingMethodForm)();
}
//]]>
</script>
现在,我不知道它从这里去。有人可以提供一些关于这是从哪里来的提示吗?
编辑:
我要补充一点,我正在寻找的是发生在该项目的权重和计算USPS运输成本的代码。我读过一个名为Usps.php的文件是计算这个速度的,但是我无法改变网站上显示的代价,即使核心文件被修改了,所以我想知道我自己的确是计算运费的代码。
'[magento]/app/code /'目录中的某些内容,但您想实现什么目标?你想从我们这里得到一个有用的答案,你对此非常模糊。 – sg3s
安装xdebug(在开发服务器上),将调试器指向它,将它设置为在开始时中断,并快速单击“下一个”,直到找到坏男孩。 – Wrikken