-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #153 Inform about empty billing address after PayPal checkout (Za…
…les0123) This PR was merged into the 1.0-dev branch. Discussion ---------- It maybe not fixes #139, but somehow handles the problem. We indeed have no place to get the billing address so it should be passed manually in the addressing step (or should be taken from the default customer address). <img width="1155" alt="Zrzut ekranu 2020-10-29 o 23 44 22" src="https://user-images.githubusercontent.com/6212718/97640272-af86ac80-1a40-11eb-9b77-78e1dc607e63.png"> Commits ------- c9da7b8 Inform about empty billing address after PayPal checkout ec68023 Check order billing address missing with twig function
- Loading branch information
Showing
6 changed files
with
69 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Resources/views/bundles/SyliusShopBundle/Common/Order/_addresses.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="ui segment"> | ||
<div class="ui {% if order.isShippingRequired() %}two{% else %}one{% endif %} column divided stackable grid"> | ||
<div class="column" id="sylius-billing-address" {{ sylius_test_html_attribute('billing-address') }}> | ||
<div class="ui small dividing header">{{ 'sylius.ui.billing_address'|trans }}</div> | ||
{% include '@SyliusShop/Common/_address.html.twig' with {'address': order.billingAddress} %} | ||
</div> | ||
{% if order.isShippingRequired() %} | ||
<div class="column" id="sylius-shipping-address" {{ sylius_test_html_attribute('shipping-address') }}> | ||
<div class="ui small dividing header">{{ 'sylius.ui.shipping_address'|trans }}</div> | ||
{% include '@SyliusShop/Common/_address.html.twig' with {'address': order.shippingAddress} %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
{% if sylius_is_billing_address_missing(order) %} | ||
<div class="ui icon message"> | ||
<i class="address card icon"></i> | ||
<div class="content"> | ||
<div class="header">{{ 'sylius.pay_pal.missing_billing_address_header'|trans }}</div> | ||
<p>{{ 'sylius.pay_pal.missing_billing_address_content'|trans }}</p> | ||
</div> | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\PayPalPlugin\Twig; | ||
|
||
use Sylius\Component\Core\Model\AddressInterface; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFunction; | ||
|
||
final class OrderAddressExtension extends AbstractExtension | ||
{ | ||
public function getFunctions(): array | ||
{ | ||
return [ | ||
new TwigFunction('sylius_is_billing_address_missing', [$this, 'isBillingAddressMissing']), | ||
]; | ||
} | ||
|
||
public function isBillingAddressMissing(OrderInterface $order): bool | ||
{ | ||
/** @var AddressInterface $billingAddress */ | ||
$billingAddress = $order->getBillingAddress(); | ||
|
||
return | ||
!$order->isShippingRequired() && | ||
$billingAddress->getStreet() === '' && | ||
$billingAddress->getPostcode() === '' && | ||
$billingAddress->getCity() === '' | ||
; | ||
} | ||
} |