Magento - 如何将新的送货地址(附加)设置为默认地址

发布于 2024-12-01 03:21:41 字数 705 浏览 4 评论 0原文

我开发了一个自定义结帐模块并且工作正常。在第一次结账时,当我输入新的帐单和送货地址时,它们被设置为默认帐单和送货地址,这很好。现在,我有一个要求,每当输入新的送货地址时,这应该成为默认的送货地址。不知何故,我无法完成这项工作。我已尝试以下操作:

$shipdata 是一个具有新地址详细信息的数组。

$shipAddress = $this->getQuote()->getShippingAddress();
$shipAddress->addData($shipdata);
$shipAddress->setIsDefaultShipping(true);

if($this->getQuote()->getDefaultShipping()) {
   $this->getQuote()->setData('default_shipping', '');
   $this->getQuote()->addAddress($shipAddress);
}
$this->getQuote()->collectTotals();
$this->getQuote()->save();

我还尝试在 $shipdata 中添加以下内容

$shipdata['default_shipping'] = 1;

,但也没有帮助。 有人可以在这方面提供帮助吗?

I developed a custom checkout module and is working fine. During checkout for the first when I enter new billing and shipping address, they are getting set as default billing and shipping address, which is fine. Now, I have a requirement, whenever a new shipping address is entered, this should become as default shipping address. Somehow, I cannot make this work. I have tried the following:

$shipdata is a array having the new address details.

$shipAddress = $this->getQuote()->getShippingAddress();
$shipAddress->addData($shipdata);
$shipAddress->setIsDefaultShipping(true);

if($this->getQuote()->getDefaultShipping()) {
   $this->getQuote()->setData('default_shipping', '');
   $this->getQuote()->addAddress($shipAddress);
}
$this->getQuote()->collectTotals();
$this->getQuote()->save();

I also tried to add the following in the $shipdata

$shipdata['default_shipping'] = 1;

but also did not help.
Can some one help in this regard?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲性难收 2024-12-08 03:21:42

您可以尝试在“customer_address_save_before”事件上使用观察者。在那里设置 isDefaultShipping 标志就可以了。我唯一不知道的是检查您是否处于结帐过程中。

You could try to use an observer on the "customer_address_save_before" event. Setting the isDefaultShipping flag there will work. Only thing I don't know is checking whether you are in the checkout process.

烟花易冷人易散 2024-12-08 03:21:42

在发布到下一页的表单中,只需包含隐藏的输入

In the form that posts to the next page simply include a hidden input

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文