Skip to content

Commit

Permalink
https://github.com/opencart/opencart/issues/11458
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Jan 24, 2023
1 parent c90c8cd commit d86801b
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 57 deletions.
3 changes: 1 addition & 2 deletions upload/admin/view/template/sale/order_info.twig
Expand Up @@ -106,6 +106,7 @@
</tr>
{% endfor %}
</tbody>

<tbody id="order-vouchers">
{% for order_voucher in order_vouchers %}
<tr>
Expand All @@ -122,13 +123,11 @@
</td>
</tr>
{% endfor %}

{% if not order_products and not order_vouchers %}
<tr>
<td colspan="6" class="text-center">{{ text_no_results }}</td>
</tr>
{% endif %}

</tbody>
<tfoot>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions upload/catalog/controller/account/order.php
Expand Up @@ -264,7 +264,7 @@ public function info(): object|null {

$subscription_id = 0;
$description = '';
/*
/*
$subscription_info = $this->model_account_subscription->getSubscriptionByOrderProductId($order_id, $product['order_product_id']);
if ($subscription_info) {
Expand All @@ -290,7 +290,7 @@ public function info(): object|null {
$description .= sprintf($this->language->get('text_subscription_cancel'), $price, $cycle, $frequency);
}
}
*/
*/
$product_info = $this->model_catalog_product->getProduct($product['product_id']);

if ($product_info) {
Expand Down
29 changes: 13 additions & 16 deletions upload/catalog/controller/account/subscription.php
Expand Up @@ -59,16 +59,6 @@ public function index(): void {
$results = $this->model_account_subscription->getSubscriptions($filter_data);

foreach ($results as $result) {
$product_info = $this->model_account_order->getProduct($result['order_id'], $result['order_product_id']);

if ($product_info) {
$product_id = $product_info['product_id'];
$product_name = $product_info['name'];
} else {
$product_id = 0;
$product_name = '';
}

$subscription_status_info = $this->model_localisation_subscription_status->getSubscriptionStatus($result['subscription_status_id']);

if ($subscription_status_info) {
Expand All @@ -79,7 +69,8 @@ public function index(): void {

$data['subscriptions'][] = [
'subscription_id' => $result['subscription_id'],
'product_name' => $product_name,
'product_id' => $result['product_id'],
'name' => $result['name'],
'product' => $this->url->link('product/product', 'language=' . $this->config->get('config_language') . '&product_id=' . $result['product_id']),
'status' => $subscription_status,
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
Expand Down Expand Up @@ -160,23 +151,29 @@ public function info(): void {

$data['date_added'] = date($this->language->get('date_format_short'), strtotime($subscription_info['date_added']));

if ($subscription_info['status']) {
$data['status'] = $this->language->get('text_status_' . $subscription_info['status']);
$this->load->model('localisation/subscription_status');

$subscription_status_info = $this->model_localisation_subscription_status->getSubscriptionStatus($subscription_info['subscription_status_id']);

if ($subscription_status_info) {
$data['status'] = $subscription_status_info['name'];
} else {
$data['status'] = '';
}

// Orders
$this->load->model('account/order');

$order_product = $this->model_account_order->getOrderProduct($subscription_info['order_id'], $subscription_info['order_product_id']);
// $order_product = $this->model_account_order->getOrderProduct($subscription_info['order_id'], $subscription_info['order_product_id']);

$data['order_id'] = $subscription_info['order_id'];
$data['reference'] = $subscription_info['reference'];
$data['product_name'] = $order_product['name'];
$data['payment_method'] = $subscription_info['payment_method'];

$data['payment_method'] = $subscription_info['payment_method'];
$data['product_quantity'] = $order_product['quantity'];
$data['description'] = $subscription_info['description'];

$data['description'] = $subscription_info['description'];

// Transactions
$data['transactions'] = [];
Expand Down
68 changes: 39 additions & 29 deletions upload/catalog/language/en-gb/account/order.php
@@ -1,37 +1,47 @@
<?php
// Heading
$_['heading_title'] = 'Order History';
$_['heading_title'] = 'Order History';

// Text
$_['text_account'] = 'Account';
$_['text_order'] = 'Order Information';
$_['text_order_detail'] = 'Order Details';
$_['text_invoice_no'] = 'Invoice No.:';
$_['text_order_id'] = 'Order ID:';
$_['text_date_added'] = 'Date Added:';
$_['text_shipping_address'] = 'Shipping Address';
$_['text_shipping_method'] = 'Shipping Method:';
$_['text_payment_address'] = 'Payment Address';
$_['text_payment_method'] = 'Payment Method:';
$_['text_comment'] = 'Order Comments';
$_['text_history'] = 'Order History';
$_['text_success'] = 'Success: You have added <a href="%s">%s</a> to your <a href="%s">shopping cart</a>!';
$_['text_no_results'] = 'You have not made any previous orders!';
$_['text_error'] = 'The order you requested could not be found!';
$_['text_account'] = 'Account';
$_['text_order'] = 'Order Information';
$_['text_order_detail'] = 'Order Details';
$_['text_invoice_no'] = 'Invoice No.:';
$_['text_order_id'] = 'Order ID:';
$_['text_date_added'] = 'Date Added:';
$_['text_shipping_address'] = 'Shipping Address';
$_['text_shipping_method'] = 'Shipping Method:';
$_['text_payment_address'] = 'Payment Address';
$_['text_payment_method'] = 'Payment Method:';
$_['text_subscription'] = 'Subscription';
$_['text_subscription_trial'] = '%s every %d %s(s) for %d payment(s) then ';
$_['text_subscription_duration'] = '%s every %d %s(s) for %d payment(s)';
$_['text_subscription_cancel'] = '%s every %d %s(s) until canceled';
$_['text_day'] = 'day';
$_['text_week'] = 'week';
$_['text_semi_month'] = 'half-month';
$_['text_month'] = 'month';
$_['text_year'] = 'year';
$_['text_comment'] = 'Order Comments';
$_['text_history'] = 'Order History';
$_['text_success'] = 'Success: You have added <a href="%s">%s</a> to your <a href="%s">shopping cart</a>!';
$_['text_no_results'] = 'You have not made any previous orders!';
$_['text_error'] = 'The order you requested could not be found!';


// Column
$_['column_order_id'] = 'Order ID';
$_['column_customer'] = 'Customer';
$_['column_product'] = 'No. of Products';
$_['column_name'] = 'Product Name';
$_['column_model'] = 'Model';
$_['column_quantity'] = 'Quantity';
$_['column_price'] = 'Price';
$_['column_total'] = 'Total';
$_['column_action'] = 'Action';
$_['column_date_added'] = 'Date Added';
$_['column_status'] = 'Status';
$_['column_comment'] = 'Comment';
$_['column_order_id'] = 'Order ID';
$_['column_customer'] = 'Customer';
$_['column_product'] = 'No. of Products';
$_['column_name'] = 'Product Name';
$_['column_model'] = 'Model';
$_['column_quantity'] = 'Quantity';
$_['column_price'] = 'Price';
$_['column_total'] = 'Total';
$_['column_action'] = 'Action';
$_['column_date_added'] = 'Date Added';
$_['column_status'] = 'Status';
$_['column_comment'] = 'Comment';

// Error
$_['error_reorder'] = '%s is not currently available to be reordered.';
$_['error_reorder'] = '%s is not currently available to be reordered.';
2 changes: 1 addition & 1 deletion upload/catalog/model/account/subscription.php
Expand Up @@ -24,7 +24,7 @@ public function getSubscriptions(array $data): array {

$implode = [];

$implode[] = "o.`customer_id` = '" . (int)$this->customer->getId() . "'";
$implode[] = "s.`customer_id` = '" . (int)$this->customer->getId() . "'";

if (!empty($data['filter_subscription_id'])) {
$implode[] = "s.`subscription_id` = '" . (int)$data['filter_subscription_id'] . "'";
Expand Down
10 changes: 6 additions & 4 deletions upload/catalog/view/template/account/order_info.twig
Expand Up @@ -68,20 +68,22 @@
{% for product in products %}
<tr>
<td class="text-start"><a href="{{ product.href }}">{{ product.name }}</a>

{% for option in product.option %}
<br/>
<small> - {{ option.name }}: {{ option.value }}</small>
{% endfor %}

{% if order_product.reward %}
{% if product.reward %}
<br/>
<small> - {{ text_points }}: {{ order_product.reward }}</small>
<small> - {{ text_points }}: {{ product.reward }}</small>
{% endif %}

{% if order_product.subscription %}
{% if product.subscription %}
<br/>
<small> - {{ text_subscription }}: <a href="index.php?route=sale/subscription.info&user_token={{ user_token }}&subscription_id={{ order_product.subscription_id }}" target="_blank">{{ order_product.subscription }}</a></small>
<small> - {{ text_subscription }}: <a href="index.php?route=sale/subscription.info&user_token={{ user_token }}&subscription_id={{ product.subscription_id }}" target="_blank">{{ order_product.subscription }}</a></small>
{% endif %}

</td>
<td class="text-start">{{ product.model }}</td>
<td class="text-end">{{ product.quantity }}</td>
Expand Down
41 changes: 38 additions & 3 deletions upload/system/helper/db_schema.php
Expand Up @@ -6407,15 +6407,30 @@ function oc_db_schema() {
'not_null' => true
],
[
'name' => 'subscription_plan_id',
'name' => 'product_id',
'type' => 'int(11)',
'not_null' => true
],
[
'name' => 'customer_payment_id',
'name' => 'product_name',
'type' => 'varchar(255)',
'not_null' => true
],
[
'name' => 'product_model',
'type' => 'varchar(64',
'not_null' => true
],
[
'name' => 'quantity',
'type' => 'int(4)',
'not_null' => true
],
[
'name' => 'subscription_plan_id',
'type' => 'int(11)',
'not_null' => true
],
],
[
'name' => 'name',
'type' => 'varchar(255)',
Expand Down Expand Up @@ -6491,11 +6506,31 @@ function oc_db_schema() {
'type' => 'datetime',
'not_null' => true
],
[
'name' => 'customer_payment_id',
'type' => 'int(11)',
'not_null' => true
],
[
'name' => 'subscription_status_id',
'type' => 'int(11)',
'not_null' => true
],
[
'name' => 'currency_id',
'type' => 'int(11)',
'not_null' => true
],
[
'name' => 'currency_code',
'type' => 'varchar(3)',
'not_null' => true
],
[
'name' => 'currency_value',
'type' => 'decimal(15,8)',
'not_null' => true
],
[
'name' => 'date_added',
'type' => 'datetime',
Expand Down

0 comments on commit d86801b

Please sign in to comment.