Closed (fixed)
Project:
Commerce Printful
Version:
2.0.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
9 May 2022 at 17:00 UTC
Updated:
24 Feb 2023 at 13:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
delty commentedI'm not much of a coder but I'm happy to help with this however I can.
Comment #3
trigdog commentedThere really isn't much that is needed to get this working. I have not fully tested it but the amount of work depends on:
Changing these two lines in the Printful.php service class gets it working (So far, I have only test the get endpoints, in postman.co, to make sure they where the same and I did synchronize products through Drupal).
First, the /store endpoint does exist in OAuth and you have to use /stores:
To:
Second, The header needs changed (if you use the apiKey field setting for the oauth token):
To:
Comment #4
delty commentedHowdy,
I tried the above changes but now get an error when attempting to sync products.
Warning: Undefined array key "name" in Drupal\commerce_printful\Form\PrintfulStoreForm->validateForm() (line 297 of /home/my_site/public_html/modules/contrib/commerce_printful/src/Form/PrintfulStoreForm.php)
Incidentally, this is with PHP 8 and using the patch from issue 3304984.
Thanks,
-=Delty
Comment #5
trigdog commentedAre you sure the Store form saved when you entered the token into the api key field? I only got that error when I did not update the endpoint for getStoreInfo to 'stores' from 'store'. Make sure that is changed in the Printful.php service class file, clear the cache, and resaved the Printful Store form with the Token in the API Key field. This is just for testing, as I am not sure the approach the maintainers of this modules want to go with this.
I attached a patch for this.
Comment #6
trigdog commentedNote: If you test this, make sure you keep a copy of your old API Key because I don't think you can get another one of those anymore.
You do have to register a new private token at https://developers.printful.com/ to test the patch.
Comment #7
trigdog commentedOrders seem to post fine to printful with the above patch in #5 but there is an error logged originating in OrderItemsTrait.php:
Warning: Undefined array key "currency" in Drupal\commerce_printful\Plugin\Commerce\ShippingMethod\PrintfulShipping->getRequestData() (line 75 of /var/www/wcs/web/modules/contrib/commerce_printful/src/OrderItemsTrait.php)
The problem is the getStoreInfo() endpoint "/stores" for OAuth does not return the default currency anymore ($store_info['result']['currency']). I have a support request into Printful about this to see how we can get that info. Will report back when I hear back.
Comment #8
DennisBradenton commentedany update on this? I am with a new install here and with a new account on printful and they deactivated the api generation.
Comment #9
trigdog commentedThey finally got back. This is their response:
"Our developer team explained that we don't expose the store's default currency in the API currently"
So we will need to remove/rework that bit of code. I will try and get to that in the next couple days.
@DennisBradenton - The patch in #5 does seem to work if you generate the new private token at https://developers.printful.com/ and paste the token in the api key field. Everything I have tested has worked and the issue mentioned in #7 is just an error that is logged and needs fixed. The orders still posts to Printful just fine and the product syncing also works.
Comment #10
cameron prince commentedHere's a patch to also resolve the problem in #4.
Comment #12
cameron prince commentedComment #13
delty commentedI just updated to the latest release and added my new API token. Everything appears to be working. I was able to sync with no errors and complete a sale so that's good news. Thanks for the update!