ethercreative / mailchimp-commerce

Mailchimp integration with Craft Commerce
Other
5 stars 11 forks source link

Syncing Orders to Mailchimp : Failed #3

Closed jacobgraf closed 5 years ago

jacobgraf commented 5 years ago

I just installed the plugin, added my API key, selected my list, and created and set my opt-in lightswitch. When I try to sync orders, it says it failed but doesn't give me any other information as to what the problem may be. Any ideas? Thanks!

https://cl.ly/765db5d6225b

alexjcollins commented 5 years ago

Hi, @jacobgraf Would you be able to take a look in your log files (web.log)? Is there anything related to Mailchimp Commerce in there?

Tam commented 5 years ago

@jacobgraf Could you search for [error][mailchimp-commerce] in your storage/logs/queue.log file?

jacobgraf commented 5 years ago

I found these errors in the queue log. I am guessing it's because these are "ticket" orders using the Verbb Events plugin for Commerce? (https://verbb.io/craft-plugins/events/features)

2019-06-26 18:57:55 [-][1][-][error][craft\queue\QueueLogBehavior::afterError] [900] Syncing Orders to Mailchimp (attempt: 1) - Error (time: 0.026s): Getting unknown property: verbb\events\elements\Ticket::product

Tam commented 5 years ago

@jacobgraf I've just pushed a release that adds support for 3rd party and Verbb Events out of the box.

jacobgraf commented 5 years ago

Thanks, but it's still failing. The fields show up properly under Field Mappings now, but the orders still don't sync. Here are some logs.

2019-06-28 07:20:56 [-][1][-][error][craft\queue\QueueLogBehavior::afterError] [943] Syncing Orders to Mailchimp (attempt: 1) - Error (time: 0.018s): Argument 1 passed to craft\helpers\UrlHelper::siteUrl() must be of the type string, null given, called in /home/forge/mysite.com/vendor/ether/mailchimp-commerce/src/services/OrdersService.php on line 292 2019-06-28 07:20:56 [-][1][-][error][TypeError] TypeError: Argument 1 passed to craft\helpers\UrlHelper::siteUrl() must be of the type string, null given, called in /home/forge/mysite.com/vendor/ether/mailchimp-commerce/src/services/OrdersService.php on line 292 and defined in /home/forge/mysite.com/vendor/craftcms/cms/src/helpers/UrlHelper.php:222

Tam commented 5 years ago

@jacobgraf Looks like the order you are trying to sync doesn't have a return URL (meaning the redirect field wasn't set when the order was paid for). I've just pushed a release to handle not having a return url.

jacobgraf commented 5 years ago

Hmm. I know the orders definitely redirect on completion. I updated to your new version but it's still failing with this error in queue.log.

2019-06-28 08:13:51 [-][1][-][error][mailchimp-commerce] Create: {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid Resource","status":400,"detail":"The resource submitted could not be validated. For field-specific details, see the 'errors' array.","instance":"3f95b17b-27fa-47b8-a57b-6b8d6ac9b733","errors":[{"field":"lines.item:0.quantity","message":"Schema describes integer, string found instead"},{"field":"customer.orders_count","message":"Schema describes integer, string found instead"}]} 2019-06-28 08:13:51 [-][1][-][error][craft\queue\QueueLogBehavior::afterError] [950] Syncing Orders to Mailchimp (attempt: 1) - Error (time: 0.091s): Failed to sync order 2019-06-28 08:13:51 [-][1][-][error][craft\db\QueryAbortedException] craft\db\QueryAbortedException: Failed to sync order in /home/forge/mysite.com/vendor/ether/mailchimp-commerce/src/jobs/SyncOrders.php:54

jacobgraf commented 5 years ago

Also, it's worth noting, the only thing I am trying to accomplish here is when an order is submitted, I want the email address for the order added to my Mailchimp list. That's what syncing orders is supposed to do, correct?

Tam commented 5 years ago

@jacobgraf Just pushed a release fixing the type casting issue. Yes, this plugin will sync customer emails to your selected Mailchimp list on order complete.

jacobgraf commented 5 years ago

Eeks.

2019-06-28 08:46:05 [-][1][-][error][mailchimp-commerce] Create: {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Bad Request","status":400,"detail":"A product with the provided ID does not exist in the account for this list.","instance":"05465a10-9d50-46f9-ab15-26d8c828c89a"} 2019-06-28 08:46:05 [-][1][-][error][craft\queue\QueueLogBehavior::afterError] [952] Syncing Orders to Mailchimp (attempt: 1) - Error (time: 0.119s): Failed to sync order 2019-06-28 08:46:05 [-][1][-][error][craft\db\QueryAbortedException] craft\db\QueryAbortedException: Failed to sync order in /home/forge/mysite.com/vendor/ether/mailchimp-commerce/src/jobs/SyncOrders.php:54

Tam commented 5 years ago

Ah, should probably better explain this on the sync page. You'll want to sync your products first, and then sync your orders. After you've synced the products once, any deletions, updates or new products will be automatically sync'd.

jacobgraf commented 5 years ago

I tried that. I also did a whole store sync. The products fail because we don't actually have any products. The only sales we do are ticket sales through Verbb Events and these are simply purchasables when the order gets placed, not Commerce products.

Tam commented 5 years ago

Have you tried since updating the plugin? I added support for Verbb Events in 1.1.0.

jacobgraf commented 5 years ago

Absolutely. I've tried it after every version.

jacobgraf commented 5 years ago

Ok. An order just came in and I tried sync products again. That completed, but sync orders is giving me this...

2019-06-28 08:59:52 [-][1][-][error][mailchimp-commerce] Create: {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Bad Request","status":400,"detail":"A product with the provided ID does not exist in the account for this list.","instance":"861c0272-1784-430c-a5ca-792a5b5cd5e5"} 2019-06-28 08:59:52 [-][1][-][error][craft\queue\QueueLogBehavior::afterError] [970] Syncing Orders to Mailchimp (attempt: 1) - Error (time: 0.133s): Failed to sync order 2019-06-28 08:59:52 [-][1][-][error][craft\db\QueryAbortedException] craft\db\QueryAbortedException: Failed to sync order in /home/forge/mysite.com/vendor/ether/mailchimp-commerce/src/jobs/SyncOrders.php:54

jacobgraf commented 5 years ago

Ok. I didn't even see the new "Sync Events" button! That is throwing this error...

2019-06-28 09:01:56 [-][1][-][error][craft\queue\QueueLogBehavior::afterError] [973] Syncing Events to Mailchimp (attempt: 1) - Error (time: 0.002s): Trying to get property 'id' of non-object 2019-06-28 09:01:56 [-][1][-][error][yii\base\ErrorException:8] yii\base\ErrorException: Trying to get property 'id' of non-object in /home/forge/mysite.com/vendor/ether/mailchimp-commerce/src/services/ProductsService.php:244

Tam commented 5 years ago

Hmm, not quite sure why that's happening. Could you try updating to the dev branch (composer require ether/mailchimp-commerce:@dev) and let me know what error is logged when the sync events task fails?

jacobgraf commented 5 years ago

Ok, I loaded the dev version. Here are the errors when I try to sync events.

2019-06-29 13:48:15 [-][1][-][info][yii\db\Command::execute] UPDATEqueueSETfail=1,dateFailed='2019-06-29 18:48:15',error='Trying to get property \'id\' of non-object' WHEREid='1106' 2019-06-29 13:48:15 [-][1][-][profile begin][yii\db\Command::execute] UPDATEqueueSETfail=1,dateFailed='2019-06-29 18:48:15',error='Trying to get property \'id\' of non-object' WHEREid='1106' 2019-06-29 13:48:15 [-][1][-][profile end][yii\db\Command::execute] UPDATEqueueSETfail=1,dateFailed='2019-06-29 18:48:15',error='Trying to get property \'id\' of non-object' WHEREid='1106'

Tam commented 5 years ago

@jacobgraf Can you email us a database dump (dev@ethercreative.co.uk)?

jacobgraf commented 5 years ago

Done.

Tam commented 5 years ago

Fixed in 1.1.3

jacobgraf commented 5 years ago

I just installed 1.1.3 and I still can't sync events or orders. Both still fail. 😢

alexjcollins commented 5 years ago

Sorry to hear that @jacobgraf! Do you get the same errors as before? We were able to sync using your database dump, so I'm wondering if it's something else causing the problem.

jacobgraf commented 5 years ago

I just emailed over some more logs.

jacobgraf commented 5 years ago

The email address you provided earlier was kicked back. 😢

alexjcollins commented 5 years ago

@jacobgraf Could you try again?

Tam commented 5 years ago

@jacobgraf You'll need to sync your events first, before syncing any orders. If you've done that, do any of your orders contain products that no longer exists?

jacobgraf commented 5 years ago

Yes but syncing events fails as well. I’ll try to get the errors associated with syncing events as soon as I can get back to a computer.

alexjcollins commented 5 years ago

Thanks @jacobgraf - really sorry about the issues you’re experiencing with the plugin so far. 😬

jacobgraf commented 5 years ago

I just emailed over the error logs for syncing events.

jacobgraf commented 5 years ago

Still doesn't work. Just sent fresh logs. 😢

jacobgraf commented 5 years ago

Uninstalled just to try to clear things out and try fresh, couldn't re-install. Looked in the DB and after uninstall there were 3 mc_ tables still in the DB so I removed those which allowed me to successfully reinstall. Tried again, and still get the errors.

jacobgraf commented 5 years ago

Ok, this is seriously starting to infuriate me. Update to 1.1.7 and still doesn't sync. Uninstalled the plugin and sure enough, your uninstaller is leaving database tables in my database so when I try to reinstall, it fails. The 3 tables it's leaving behind are...

mc_orders_synced mc_products_synced mc_promos_synced

jacobgraf commented 5 years ago

Ok. After uninstalling/reinstalling, the events and orders now sync successfully, but you might want to look into why those three tables aren't getting flushed on uninstall. Thanks.