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

[4.0.0.0] Subscription-related bugs #11458

Open
ClearThinking opened this issue Jul 11, 2022 · 15 comments
Open

[4.0.0.0] Subscription-related bugs #11458

ClearThinking opened this issue Jul 11, 2022 · 15 comments
Assignees
Labels
In Progress We are currently working on a fix/update

Comments

@ClearThinking
Copy link

The following errors appear when checking out with a subscription product (i.e. a product that has a subscription plan attached to it) in the final step of checkout:

Warning: Undefined array key "date_next" in /catalog/model/checkout/order.php on line 37
Warning: Undefined array key "customer_id" in /catalog/model/checkout/subscription.php on line 5
Warning: Undefined array key "subscription_plan_id" in /catalog/model/checkout/subscription.php on line 5

The "date_next" field is not listed anywhere in the cart library, so perhaps it's just an old variable that needs to be removed. For the other two, you should be able to fix those errors by making this edit:

IN:
/catalog/model/checkout/order.php

AFTER:
'order_product_id' => $order_product_id,

ADD:
'customer_id' => $data['customer_id'],
'subscription_plan_id' => $product['subscription']['subscription_plan_id'],
@ClearThinking
Copy link
Author

It looks like another edit is necessary for when the order is updated, if you reload the checkout page. Here's that edit:

IN:
/catalog/model/checkout/order.php

REPLACE:
$this->model_checkout_subscription->addSubscription($order_id, $product['subscription'] + ['order_product_id' => $order_product_id]);

WITH:
$this->model_checkout_subscription->addSubscription($order_id, $product['subscription'] + ['order_product_id' => $order_product_id, 'customer_id' => $data['customer_id']]);

@miroslav-sc
Copy link

Hi,
I use OC 4.0.1.1 and find similar problem:

Undefined array key "customer_id" in \catalog\model\checkout\subscription.php on line 5
Undefined array key "trial_remaining" in \catalog\model\checkout\subscription.php on line 5
Undefined array key "date_next" in \catalog\model\checkout\subscription.php on line 5
TypeError: Opencart\System\Library\DB::escape(): Argument #1 ($value) must be of type string, null given, called in
\catalog\model\checkout\subscription.php on line 5 in \system\library\db.php on line 56

I just tried to open the checkout after enabled Subscriptions for my payment module.
Any information?

@TheCartpenter
Copy link
Contributor

Hi, I use OC 4.0.1.1 and find similar problem:

Undefined array key "customer_id" in \catalog\model\checkout\subscription.php on line 5 Undefined array key "trial_remaining" in \catalog\model\checkout\subscription.php on line 5 Undefined array key "date_next" in \catalog\model\checkout\subscription.php on line 5 TypeError: Opencart\System\Library\DB::escape(): Argument #1 ($value) must be of type string, null given, called in \catalog\model\checkout\subscription.php on line 5 in \system\library\db.php on line 56

I just tried to open the checkout after enabled Subscriptions for my payment module. Any information?

@miroslav-sc : With the latest changes in the subscriptions, does this issue still occur? This may particularly happen if people were upgrading from previous OC releases to OC 4.x whereas the default field was not added in the address table on the database which has been recently added into the upgrade process as I was able to reproduce this issue previously.

@miroslav-sc
Copy link

miroslav-sc commented Nov 15, 2022

Hi, I use OC 4.0.1.1 and find similar problem:
Undefined array key "customer_id" in \catalog\model\checkout\subscription.php on line 5 Undefined array key "trial_remaining" in \catalog\model\checkout\subscription.php on line 5 Undefined array key "date_next" in \catalog\model\checkout\subscription.php on line 5 TypeError: Opencart\System\Library\DB::escape(): Argument #1 ($value) must be of type string, null given, called in \catalog\model\checkout\subscription.php on line 5 in \system\library\db.php on line 56
I just tried to open the checkout after enabled Subscriptions for my payment module. Any information?

@miroslav-sc : With the latest changes in the subscriptions, does this issue still occur? This may particularly happen if people were upgrading from previous OC releases to OC 4.x whereas the default field was not added in the address table on the database which has been recently added into the upgrade process as I was able to reproduce this issue previously.

Hi,

My test was on clean install with OC 4.0.1.1, but if no one can confirm it I can make another clean install and repeat the test.

Regards!

@TheCartpenter
Copy link
Contributor

Hi, I use OC 4.0.1.1 and find similar problem:
Undefined array key "customer_id" in \catalog\model\checkout\subscription.php on line 5 Undefined array key "trial_remaining" in \catalog\model\checkout\subscription.php on line 5 Undefined array key "date_next" in \catalog\model\checkout\subscription.php on line 5 TypeError: Opencart\System\Library\DB::escape(): Argument #1 ($value) must be of type string, null given, called in \catalog\model\checkout\subscription.php on line 5 in \system\library\db.php on line 56
I just tried to open the checkout after enabled Subscriptions for my payment module. Any information?

@miroslav-sc : With the latest changes in the subscriptions, does this issue still occur? This may particularly happen if people were upgrading from previous OC releases to OC 4.x whereas the default field was not added in the address table on the database which has been recently added into the upgrade process as I was able to reproduce this issue previously.

Hi,

My test was on clean install with OC 4.0.1.1, but if no one can confirm it I can make another clean install and repeat the test.

Regards!

Hi,

Please try with a new clean installation and report back if the issue still persists since the latest changes.

@miroslav-sc
Copy link

Hi, I use OC 4.0.1.1 and find similar problem:
Undefined array key "customer_id" in \catalog\model\checkout\subscription.php on line 5 Undefined array key "trial_remaining" in \catalog\model\checkout\subscription.php on line 5 Undefined array key "date_next" in \catalog\model\checkout\subscription.php on line 5 TypeError: Opencart\System\Library\DB::escape(): Argument #1 ($value) must be of type string, null given, called in \catalog\model\checkout\subscription.php on line 5 in \system\library\db.php on line 56
I just tried to open the checkout after enabled Subscriptions for my payment module. Any information?

@miroslav-sc : With the latest changes in the subscriptions, does this issue still occur? This may particularly happen if people were upgrading from previous OC releases to OC 4.x whereas the default field was not added in the address table on the database which has been recently added into the upgrade process as I was able to reproduce this issue previously.

Hi,
My test was on clean install with OC 4.0.1.1, but if no one can confirm it I can make another clean install and repeat the test.
Regards!

Hi,

Please try with a new clean installation and report back if the issue still persists since the latest changes.

Hi,

I just made my test:

I used xampp-windows-x64-8.0.3-0-VS16.
On it I added clean install of OC 4.0.1.1.
Then create a Subscription Plan. In my opinion you have to enable Trail Duration to be 0, it will be same as it is disabled.
I attached the Plan ot the iPhone. Because the default Payment options does not support Subscription, I added the Payment Gateway I work on. It was tested soon, and works without problem.
I added registered user, logged in, and added the iPhone to the Cart, selected shipping method, then payment method - mine was the only available.
But instead load the fields of my gateway a message was shown:

Warning: Undefined array key "date_next" in C:\xampp8030\htdocs\opencart-4\catalog\model\checkout\order.php on line 40Warning: Undefined array key "trial_remaining" in C:\xampp8030\htdocs\opencart-4\catalog\model\checkout\subscription.php on line 5TypeError: Opencart\System\Library\DB::escape(): Argument #1 ($value) must be of type string, null given, called in C:\xampp8030\htdocs\opencart-4\catalog\model\checkout\subscription.php on line 5 in C:\xampp8030\htdocs\opencart-4\system\library\db.php on line 56

On my dev site I find where this problems come from, and when add the missing parameters with some dummy values the Payment and the Subscription work fine.

I hope this will help you!
Regards!

@TheCartpenter
Copy link
Contributor

See if you have the most updated changes about the trial_remaining field in your system/library/cart/cart.php file. A recent fix was posted about it around last week. As for the date_next field, this is intended since you need an extension that is linked via a reliable service provider to confirm this field during checkout and with the orders API.

@miroslav-sc
Copy link

miroslav-sc commented Nov 17, 2022

See if you have the most updated changes about the trial_remaining field in your system/library/cart/cart.php file. A recent fix was posted about it around last week. As for the date_next field, this is intended since you need an extension that is linked via a reliable service provider to confirm this field during checkout and with the orders API.

I will check for the fix, because my download of 4.0.1.1 was about may be a month ago.
And about the date_next, do I have to get this extension from somewhere or I have to write it and include it in my payment module?

Regards!

@TheCartpenter
Copy link
Contributor

TheCartpenter commented Nov 17, 2022

See if you have the most updated changes about the trial_remaining field in your system/library/cart/cart.php file. A recent fix was posted about it around last week. As for the date_next field, this is intended since you need an extension that is linked via a reliable service provider to confirm this field during checkout and with the orders API.

I will check for the fix, because my download of 4.0.1.1 was about may be a month ago. And about the date_next, do I have to get this extension from somewhere or I have to write it and include it in my payment module?

Regards!

Both; in the OC Marketplace.

@danielkerr
Copy link
Member

danielkerr commented Jan 21, 2023

@TheCartpenter all the commits u have done over the months for subscript and still loads of stuff throwing errors.

@opencartbot
Copy link
Contributor

Now I get an error in the process of installing the master version

Exception: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL, `quantity` int(4) NOT NULL, `subscription_plan_id` int(11) NOT NUL' at line 8
Error No: 1064
CREATE TABLE `oc_subscription` ( `subscription_id` int(11) NOT NULL AUTO_INCREMENT, `customer_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `order_product_id` int(11) NOT NULL, `product_id` int(11) NOT NULL, `product_name` varchar(255) NOT NULL, `product_model` **varchar(64** NOT NULL, `quantity` int(4) NOT NULL, `subscription_plan_id` int(11) NOT NULL, `name` varchar(255) NOT NULL, `description` text NOT NULL, `reference` varchar(255) NOT NULL, `trial_price` decimal(10,4) NOT NULL, `trial_frequency` enum('day','week','semi_month','month','year') NOT NULL, `trial_cycle` smallint(6) NOT NULL, `trial_duration` smallint(6) NOT NULL, `trial_remaining` smallint(6) NOT NULL, `trial_status` tinyint(1) NOT NULL, `price` decimal(10,4) NOT NULL, `frequency` enum('day','week','semi_month','month','year') NOT NULL, `cycle` smallint(6) NOT NULL, `duration` smallint(6) NOT NULL, `remaining` smallint(6) NOT NULL, `date_next` datetime NOT NULL, `customer_payment_id` int(11) NOT NULL, `subscription_status_id` int(11) NOT NULL, `currency_id` int(11) NOT NULL, `currency_code` varchar(3) NOT NULL, `currency_value` decimal(15,8) NOT NULL, `date_added` datetime NOT NULL, `date_modified` datetime NOT NULL, PRIMARY KEY (`subscription_id`), KEY `order_id` (`order_id`) ) ENGINE=InnoDB CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COLLATE=utf8mb4_general_ci; in /system/library/db/mysqli.php on line 64

@danielkerr
Copy link
Member

Did I say it's finished?

@pemaier
Copy link
Contributor

pemaier commented Jul 13, 2023

What version of OpenCart are you reporting this for?
master
Describe the bug
A clear and concise description of what the bug is
What section does it affect? Report

After a new install

  • save Settings
  • when opening Report / Customer Subscription Report an error occur. -
    Exception: Error: Table 'aqq20848_opencart_master_demo.oc_subscription_transaction' doesn't exist
    Error No: 1146
    SELECT COUNT(DISTINCT s.customer_id) AS total FROM oc_subscription_transaction st LEFT JOIN oc_subscription s ON (st.subscription_id = s.subscription_id) LEFT JOIN oc_customer c ON (s.customer_id = c.customer_id) in /home/aqq20848/public_html/opencart/master.demo/system/library/db/mysqli.php on line 68

Server / Test environment (please complete the following information):

  • Local development? Deployed to a web server? server
  • Operating system linux
  • PHP version 8.2
  • Apache version 2.4
  • Browser(s) tested with [e.g. chrome, safari - if applicable] FF
  • Version [e.g. 22] 115.0.2

@AJenbo
Copy link
Collaborator

AJenbo commented Nov 7, 2023

Hopefully this will contribute to solving this issue: #12902

@AJenbo
Copy link
Collaborator

AJenbo commented Nov 10, 2023

One more related to this issue: #12916

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In Progress We are currently working on a fix/update
Projects
None yet
Development

No branches or pull requests

7 participants