digitalwithyou / craft-facebook-conversion

Craft CMS plugin to send web events directly to Facebook
https://digitalwithyou.com/en/plugins/facebook-conversion/getting-started
Other
0 stars 3 forks source link

Error when trying to create an order manually inside a queued Job #28

Closed sajjanstha closed 1 year ago

sajjanstha commented 1 year ago

Hi @Diewy

We are facing the following issue when we tried to create an order manually inside a queued Job and mark it as complete:

[error][yii\base\ErrorException:2] yii\base\ErrorException: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent in /app/vendor/yiisoft/yii2/web/Session.php:430
Stack trace:
#0 /app/vendor/craftcms/cms/src/web/ErrorHandler.php(84): craft\web\ErrorHandler->handleError('2', ''session_set_co...', ''/app/vendor/yi...', '430')
#1 /app/vendor/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php(154): craft\web\ErrorHandler->handleError('2', ''session_set_co...', ''/app/vendor/yi...', '430')
#2 /app/vendor/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php(154): ::call_user_func_array:{/app/vendor/facebook/php-business-sdk/src/FacebookAds/CrashReporter.php:154}

You can replicate the issue by executing the following code inside a Job:

        $order = new Order();
        //replace the customerId with one existing in your database table craft_commerce_customers
        $customerId = 1;
        $customer = Commerce::getInstance()->customers->getCustomerById($customerId);
        $order->customerId = $customer->id;
        $order->email = $customer->email;
        $order->number = md5(uniqid(mt_rand(), true));
        Craft::$app->getElements()->saveElement($order);
        $order->markAsComplete();

I have tested the above code to be working outside a Job without any problem. The error is received only when run on Job.

We are using:

Craft CMS v3.7.48 Facebook Conversion v1.1.0

bernsno commented 1 year ago

Hi, @Diewy Just wanted to follow up on this. We're paying for the Facebook Conversion plugin and it's working well, except that we need to disable it when we need to generate orders. Can you please let us know if it's possible to look into this?

Diewy commented 1 year ago

Hi @sajjanstha and @bernsno,

Support without active sessions is added in the latest release which resolves the issue.

Thank you for reporting!

sajjanstha commented 1 year ago

Thanks @Diewy , the issue is fixed now