Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes to Orders page #16075

Merged
merged 5 commits into from Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -400,6 +400,10 @@ private function getOrderProducts(Order $order): OrderProductsForViewing
$unitPriceFormatted = $this->locale->formatPrice($unitPrice, $currency->iso_code);
$totalPriceFormatted = $this->locale->formatPrice($totalPrice, $currency->iso_code);

$imagePath = isset($product['image_tag']) ?
$this->imageTagSourceParser->parse($product['image_tag']) :
null;

$productsForViewing[] = new OrderProductForViewing(
$product['id_order_detail'],
$product['product_id'],
Expand All @@ -410,7 +414,7 @@ private function getOrderProducts(Order $order): OrderProductsForViewing
$unitPriceFormatted,
$totalPriceFormatted,
$product['current_stock'],
$this->imageTagSourceParser->parse($product['image_tag']),
$imagePath,
Tools::ps_round($product['unit_price_tax_excl'], 2),
Tools::ps_round($product['unit_price_tax_incl'], 2)
);
Expand Down
19 changes: 11 additions & 8 deletions src/Adapter/Order/QueryHandler/GetOrderPreviewHandler.php
Expand Up @@ -44,6 +44,7 @@
use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId;
use PrestaShop\PrestaShop\Core\Localization\Locale\Repository as LocaleRepository;
use State;
use StockAvailable;
use Validate;

/**
Expand Down Expand Up @@ -123,8 +124,8 @@ private function getInvoiceDetails(Order $order): OrderPreviewInvoiceDetails
$stateName = Validate::isLoadedObject($state) ? $state->name : null;

return new OrderPreviewInvoiceDetails(
$customer->firstname,
$customer->lastname,
$address->firstname,
$address->lastname,
$address->company,
$address->vat_number,
$address->address1,
Expand All @@ -134,8 +135,7 @@ private function getInvoiceDetails(Order $order): OrderPreviewInvoiceDetails
$stateName,
$country->name[$order->id_lang],
$customer->email,
$address->phone,
$address->company
$address->phone
);
}

Expand All @@ -144,7 +144,6 @@ private function getInvoiceDetails(Order $order): OrderPreviewInvoiceDetails
*/
private function getShippingDetails(Order $order): OrderPreviewShippingDetails
{
$customer = new Customer($order->id_customer);
$address = new Address($order->id_address_delivery);
$country = new Country($address->id_country);
$carrier = new Carrier($order->id_carrier);
Expand All @@ -161,8 +160,8 @@ private function getShippingDetails(Order $order): OrderPreviewShippingDetails
$orderCarrier = new OrderCarrier($orderCarrierId);

return new OrderPreviewShippingDetails(
$customer->firstname,
$customer->lastname,
$address->firstname,
$address->lastname,
$address->company,
$address->vat_number,
$address->address1,
Expand Down Expand Up @@ -205,7 +204,11 @@ private function getProductDetails(Order $order): array
$productDetails[] = new OrderPreviewProductDetail(
$detail['product_name'],
$detail['product_reference'],
$detail['location'],
StockAvailable::getLocation(
$detail['product_id'],
$detail['product_attribute_id'],
$detail['id_shop']
),
(int) $detail['product_quantity'],
$locale->formatPrice($unitPrice, $currency->iso_code),
$locale->formatPrice($totalPrice, $currency->iso_code),
Expand Down
Expand Up @@ -69,7 +69,7 @@ class OrderProductForViewing
private $availableQuantity;

/**
* @var string
* @var string|null
*/
private $imagePath;

Expand Down Expand Up @@ -98,7 +98,7 @@ public function __construct(
string $unitPrice,
string $totalPrice,
int $availableQuantity,
string $imagePath,
?string $imagePath,
float $unitPriceTaxExclRaw,
float $unitPriceTaxInclRaw
) {
Expand Down Expand Up @@ -189,9 +189,9 @@ public function getAvailableQuantity(): int
}

/**
* @return string
* @return string|null
*/
public function getImagePath(): string
public function getImagePath(): ?string
{
return $this->imagePath;
}
Expand Down
Expand Up @@ -471,8 +471,8 @@ private function getRowActions(): RowActionCollection
->setName($this->trans('View', [], 'Admin.Actions'))
->setIcon('zoom_in')
->setOptions([
'route' => 'admin_orders_index',
'route_param_name' => 'id_order',
'route' => 'admin_orders_view',
'route_param_name' => 'orderId',
'route_param_field' => 'id_order',
'use_inline_display' => true,
])
Expand Down
Expand Up @@ -59,14 +59,20 @@
<tbody>
{% for product in orderForViewing.products.products %}
<tr>
<td><img src="{{ product.imagePath }}" alt="{{ product.name }}"></td>
<td>
{% if product.imagePath %}
<img src="{{ product.imagePath }}" alt="{{ product.name }}">
{% endif %}
</td>
<td>
<a href="{{ path('admin_product_form', {'id': product.id}) }}">
<p class="mb-0">{{ product.name }}</p>
<p class="mb-0">
{{ 'Reference number:'|trans({}, 'Admin.Orderscustomers.Feature') }}
{{ product.reference }}
</p>
{% if product.reference %}
<p class="mb-0">
{{ 'Reference number:'|trans({}, 'Admin.Orderscustomers.Feature') }}
{{ product.reference }}
</p>
{% endif %}
{% if product.supplierReference is not empty %}
<p class="mb-0">
{{ 'Supplier reference:'|trans({}, 'Admin.Orderscustomers.Feature') }}
Expand Down
Expand Up @@ -25,7 +25,7 @@

{% block order_preview %}
<div class="row order-preview-content mt-2">
<div class="col-4">
<div class="col-5">
<div class="row">
<div class="col">
<div class="row">
Expand Down Expand Up @@ -119,7 +119,7 @@
</div>
</div>
</div>
<div class="offset-1 col-7">
<div class="col-7">
<div class="table-responsive">
<table class="table product table-borderless border-bottom-0">
<thead>
Expand Down