Forum Replies Created

Viewing 6 replies - 16 through 21 (of 21 total)
  • Thread Starter amirhmoradi

    (@amirhmoradi)

    Hi, unfortunately, it seems the conflict is still there and happens in some cases. For example it happens when accessing some orders or updating them in the woocommerce order management page.
    Here is the trace of the error i caught today while updating an order to the ‘completed’ status:

    [14-Dec-2023 14:12:32 UTC] PHP Fatal error:  Uncaught TypeError: FluentForm\Framework\Database\BaseGrammar::columnize(): Argument #1 ($columns) must be of type array, string given, called in /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Grammar.php on line 121 and defined in /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/BaseGrammar.php:107
    Stack trace:
    
    #0 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Grammar.php(121): FluentForm\Framework\Database\BaseGrammar->columnize()
    
    #1 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Grammar.php(75): FluentForm\Framework\Database\Query\Grammar->compileColumns()
    
    #2 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Grammar.php(51): FluentForm\Framework\Database\Query\Grammar->compileComponents()
    
    #3 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/MySqlGrammar.php(39): FluentForm\Framework\Database\Query\Grammar->compileSelect()
    
    #4 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Builder.php(1558): FluentForm\Framework\Database\Query\MySqlGrammar->compileSelect()
    
    #5 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Builder.php(1627): FluentForm\Framework\Database\Query\Builder->toSql()
    
    #6 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Builder.php(1613): FluentForm\Framework\Database\Query\Builder->runSelect()
    
    #7 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Builder.php(1594): FluentForm\Framework\Database\Query\Builder->get()
    
    #8 /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/Query/Builder.php(1570): FluentForm\Framework\Database\Query\Builder->first()
    
    #9 /var/www/vhosts/example.com/html/wp-content/plugins/reviewx/app/Controllers/Admin/Email/ReminderEmail.php(63): FluentForm\Framework\Database\Query\Builder->find()
    
    #10 /var/www/vhosts/example.com/html/wp-content/plugins/reviewx/app/Controllers/Admin/Email/EmailSettings.php(351): ReviewX\Controllers\Admin\Email\ReminderEmail->getEmailLog()
    
    #11 /var/www/vhosts/example.com/html/wp-content/plugins/reviewx/app/Hooks/Backend.php(83): ReviewX\Controllers\Admin\Email\EmailSettings->processSingleEmail()
    
    #12 /var/www/vhosts/example.com/html/wp-includes/class-wp-hook.php(326): JoulesLabs\Warehouse\Foundation\Application->{closure}()
    
    #13 /var/www/vhosts/example.com/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    
    #14 /var/www/vhosts/example.com/html/wp-includes/plugin.php(517): WP_Hook->do_action()
    
    #15 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/includes/class-wc-order.php(411): do_action()
    
    #16 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/includes/class-wc-order.php(253): WC_Order->status_transition()
    
    #17 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php(714): WC_Order->save()
    
    #18 /var/www/vhosts/example.com/html/wp-includes/class-wp-hook.php(326): WC_Meta_Box_Order_Data::save()
    
    #19 /var/www/vhosts/example.com/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    
    #20 /var/www/vhosts/example.com/html/wp-includes/plugin.php(517): WP_Hook->do_action()
    
    #21 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php(233): do_action()
    
    #22 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/Edit.php(147): Automattic\WooCommerce\Internal\Admin\Orders\Edit->handle_order_update()
    
    #23 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/PageController.php(350): Automattic\WooCommerce\Internal\Admin\Orders\Edit->setup()
    
    #24 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/PageController.php(366): Automattic\WooCommerce\Internal\Admin\Orders\PageController->prepare_order_edit_form()
    
    #25 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/src/Internal/Admin/Orders/PageController.php(167): Automattic\WooCommerce\Internal\Admin\Orders\PageController->setup_action_edit_order()
    
    #26 [internal function]: Automattic\WooCommerce\Internal\Admin\Orders\PageController->handle_load_page_action()
    
    #27 /var/www/vhosts/example.com/html/wp-content/plugins/woocommerce/src/Internal/Traits/AccessiblePrivateMethods.php(158): call_user_func_array()
    
    #28 /var/www/vhosts/example.com/html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Internal\Admin\Orders\PageController->__call()
    
    #29 /var/www/vhosts/example.com/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    
    #30 /var/www/vhosts/example.com/html/wp-includes/plugin.php(517): WP_Hook->do_action()
    
    #31 /var/www/vhosts/example.com/html/wp-admin/admin.php(237): do_action()
    
    #32 {main}
    
      thrown in /var/www/vhosts/example.com/html/wp-content/plugins/fluentform/vendor/wpfluent/framework/src/WPFluent/Database/BaseGrammar.php on line 107
    Thread Starter amirhmoradi

    (@amirhmoradi)

    Hi, Thanks for your feedback and the provided file.

    After updating to the latest version (reviewx.1.6.23) this issue seems to be resolved.

    BTW, I compared the provided modified version with the latest release and could not identify the code that is supposed to address the issue.

    Regards.

    Hi @sammymlangeni @haseeb0001 ,
    It should be quite simple to fix this. Before moving on, we shall check the type of $licenses and $license["keys"][0] in the example above, and act accordingly.

    To make sure I understand your request @haseeb0001, let me rephrase:
    NB: We shall not mix concepts of :
    number of license keys per product,
    number of activations possible per license
    number of licenses per order

    * A customer makes a purchase order (ORD_ID: 1780), containing multiple licenses (LIC_ID: 3, LIC_ID:4, LIC_ID:5,…) with each license having ONLY ONE key.

    * You expect WC API to have the following response structure:

    ...
    "date_paid_gmt": "2022-04-22T17:52:51",
        "currency_symbol": "€",
        "license_lines": [
            {
                "id": 3,
                "product_id": 1761,
                "product_name": "Premium - 1 year",
                "order_id": 1780,
                "key": "XYZ-ABC-AG5V-9900-VPNM",
                "expires_at": "2023-04-22 17:52:51",
                "valid_for_days": 365,
                "source": 1,
                "status": 2,
                "times_activated": null,
                "times_activated_max": 1
            },
            {
                "id": 4,
                "product_id": 1762,
                "product_name": "Premium - 2 year",
                "order_id": 1780,
                "key": "XYZ-ABC-AG5V-8800-VPNL",
                "expires_at": "2023-04-22 17:52:51",
                "valid_for_days": 365,
                "source": 1,
                "status": 2,
                "times_activated": null,
                "times_activated_max": 1
            },
            {
                "id": 5,
                "product_id": 1763,
                "product_name": "Premium - 3 year",
                "order_id": 1780,
                "key": "XYZ-ABC-AG5V-7700-VPNK",
                "expires_at": "2023-04-22 17:52:51",
                "valid_for_days": 365,
                "source": 1,
                "status": 2,
                "times_activated": null,
                "times_activated_max": 1
            }
        ],
        "_links": {
            "self": [
    
    ...

    Did I understand correctly?

    @frankgao714 @arsalantariq
    Hi,
    Here is a solution I use (of course it can be improved, all suggestions are welcome!)

    Instead of adding this feature to the plugin, I added it to Woocommerce API endpoint. This way; when you get an order from Woocommerce API, it would also contain info about purchased licenses.

    Here is the example output:
    GET https://example.com/wp-json/wc/v3/orders/1780

    Response snippet:

    
    ...
    "date_paid_gmt": "2022-04-22T17:52:51",
        "currency_symbol": "€",
        "license_lines": [
            {
                "id": 3,
                "product_id": 1761,
                "product_name": "Premium - 1 year",
                "order_id": 1780,
                "key": "XYZ-ABC-AG5V-9900-VPNM",
                "expires_at": "2023-04-22 17:52:51",
                "valid_for_days": 365,
                "source": 1,
                "status": 2,
                "times_activated": null,
                "times_activated_max": 1
            }
        ],
        "_links": {
            "self": [
    
    ...
    

    To make this happen; add this code to your theme’s functions.php file:

    function add_licenses_to_order_api_data ( $response, $order, $request ) {
    	$licenses = apply_filters('lmfwc_get_customer_license_keys', $order);
    	foreach ($licenses as $prd_id => $license) {
    		$prd_name = $license["name"];
    		$license = $license["keys"][0];
    		$license_line = [ "id" => $license->getId(),
    						  "product_id" => $license->getProductId(),
    						  "product_name" => $prd_name,
    						  "order_id" => $license->getOrderId(),
    						  "key" => $license->getDecryptedLicenseKey(),
    						  "expires_at" => $license->getExpiresAt(),
    						  "valid_for_days" => $license->getValidFor(),
    						  "source" => $license->getSource(),
    						  "status" => $license->getStatus(),
    						  "times_activated" => $license->getTimesActivated(),
    						  "times_activated_max" => $license->getTimesActivatedMax(),
    						];
    		$license_lines[] = $license_line;
    	}
    	$response->data['license_lines'] = $license_lines;
    	
    	return $response;
    }
    add_filter( 'woocommerce_rest_prepare_shop_order_object', 'add_licenses_to_order_api_data',10 ,3);
    Thread Starter amirhmoradi

    (@amirhmoradi)

    Tried your suggestion and it works!
    Thanks a lot for your great work and support ??

    Thread Starter amirhmoradi

    (@amirhmoradi)

    Hi, thanks for your update.
    The plugin installs and runs but cannot find the upload path.
    It adds a duplicate /sites/<site_id> at the end of a supposed uploads path and resulting finally in : /wp-content/uploads/sites/<site_id>/sites/<site_id>

    And so it cannot find any files

    Thanks.

Viewing 6 replies - 16 through 21 (of 21 total)