С самого начала я хочу извиниться за мой плохой английский! У меня есть задача сделать правильное хранение информации в клиентской сессии в Magento на странице оформления заказа. Когда я пытаюсь сохранить платежный адрес гостевого пользователя, я переписываю модель выставления счетов, и все в порядке. Но когда пользователь вошел в систему и имеет несколько адресов в своей адресной книге, я увидел интересную вещь .... Мне пришлось переписать модель биллинга, чтобы сохранить идентификатор адреса клиента и сохранить выбранный адрес, но когда пользователь выбирает опцию в выберите «Новый адрес» , данные формы сохраняются в кавычках, и когда я пытаюсь получить их с помощью getQuote()->getBillingAddress(), я беру адрес пользователя по умолчанию (когда пользователь не вошел в систему, все работает хорошо). Как я могу выполнить эту задачу?? Мне нужна помощь, потому что это важная задача для меня ... Большое спасибо !!!
Magento сохранить платежный адрес в Quote
comment
почему нет ответов??? мой вопрос в плохом стиле?
- person Alex-dev   schedule 17.11.2011
Ответы (1)
Если я правильно разобрал ваш вопрос, вы говорите, что getQuote()->getBillingAddress()
получает платежный адрес клиента по умолчанию вместо нового адреса, который клиент ввел в заказе?
У меня есть эта проблема и в Magento 1.4.0.1, я обошел ее, получив все адреса от клиента и сравнив каждый атрибут с адресом, указанным в заказе, чтобы узнать реальный идентификатор объекта адреса.
Я скопировал это из своего кода с удалением некоторых частей пользовательской бизнес-логики, так что считайте это непроверенным, но вы поняли идею:
(Код протестирован только на Magento 1.4.0.1 и может не применяться к Magento 1.5)
$currentCustomer = Mage::getModel('customer/customer')->load($order['customer_id']);
$attributesToCompare = array('firstname', 'lastname', 'country_id', 'region', 'region_id', 'city', 'telephone', 'postcode', 'company', 'fax', 'prefix', 'middlename', 'suffix', 'street');
$orderAddresses = array(
'billing' => $order->getBillingAddress()->getData(),
'shipping' => $order->getShippingAddress()->getData()
);
$foundExistingCustomerAddressEntityId = array(
'billing' => false,
'shipping' => false
);
$billingSameAsShipping = false;
$currentCustomerAddresses = $currentCustomer->getAddressesCollection();
// is the billing/shipping address currently found in the customer's address book?
foreach ($orderAddresses as $orderAddressKey => $orderAddress) {
//var_dump($orderAddress);
foreach ($currentCustomerAddresses as $currentCustomerAddressObj) {
$currentCustomerAddress = $currentCustomerAddressObj->getData();
$attributesMatchCount = 0;
foreach ($attributesToCompare as $attributeToCompare) {
if (empty($currentCustomerAddress[$attributeToCompare])) {
$currentCustomerAddress[$attributeToCompare] = false;
}
$attributesMatchCount += ($orderAddress[$attributeToCompare] == $currentCustomerAddress[$attributeToCompare])?1:0;
//echo 'attributesMatchCount: '.$attributesMatchCount." {$orderAddress[$attributeToCompare]} {$currentCustomerAddress[$attributeToCompare]}\n";
}
if ($attributesMatchCount == count($attributesToCompare)) {
$foundExistingCustomerAddressEntityId[$orderAddressKey] = $currentCustomerAddress['entity_id'];
//echo 'foundExistingCustomerAddressEntityId['.$orderAddressKey.']: '.$foundExistingCustomerAddressEntityId[$orderAddressKey]."\n\n";
break;
}
}
}
$billingShippingExactMatchCount = 0;
foreach ($attributesToCompare as $attributeToCompare) {
$billingShippingExactMatchCount += ($orderAddresses['billing'][$attributeToCompare] == $orderAddresses['shipping'][$attributeToCompare])?1:0;
}
if ($billingShippingExactMatchCount == count($attributesToCompare)) {
$billingSameAsShipping = true;
}
person
Community
schedule
31.05.2012