【发布时间】:2015-11-12 18:28:53
【问题描述】:
您好,我正在尝试使用以下代码即时更改运费,但是当费率尝试保存时它会崩溃:
$shippingprice = 20.00;
$address = $quote->getShippingAddress();
$address->setShippingAmount($shippingprice);
$address->setBaseShippingAmount($shippingprice);
$rates = $address->collectShippingRates()
->getGroupedAllShippingRates();
$address->setCollectShippingRates(false);
$address->save();
foreach ($rates as $carrier) {
foreach ($carrier as $rate) {
$rate->setPrice($shippingprice);
$rate->save();//Right here it crash
}
}
SQLSTATE[23000]:完整性约束违规:1452 无法添加或更新子行:外键约束失败(sales_flat_quote_shipping_rate, CONSTRAINT FK_B1F177EFB73D3EDF5322BA64AC48D150 FOREIGN KEY (address_id) REFERENCES sales_flat_quote_address (address_id ) ),查询为:INSERT INTO sales_flat_quote_shipping_rate (created_at, updated_at, carrier, carrier_title, code, method, method_description, method_title, @VALUES (4336@) '2015-11-12 18:22:52', '2015-11-12 18:22:52', ?, ?, ?, ?, ?, ?, ?)
知道这个错误吗?
谢谢
【问题讨论】: