Home › Forums › WoodMart support forum › Problem with REST API (PUT in products/attributes)
Problem with REST API (PUT in products/attributes)
- This topic has 11 replies, 2 voices, and was last updated 6 years, 1 month ago by Artem Temos.
-
AuthorPosts
-
December 3, 2018 at 4:48 pm #93474
jcmachadoParticipantI’m trying to sync my ERP data with my WooCommerce Store and, after installing Woodmart Theme, I’m getting the following error trying to update the Product Attributes:
Uncaught Error: Call to undefined function woodmart_admin_scripts_localize()
What is the workaround?
Following, the complete error log:Notice: Undefined index: attribute_swatch_size in /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php on line 17
Notice: Undefined index: attribute_show_on_product in /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php on line 19
Fatal error: Uncaught Error: Call to undefined function woodmart_admin_scripts_localize() in /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php:22 Stack trace: #0 /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-includes/class-wp-hook.php(286): woodmart_wc_attribute_update(387, Array, ‘carne-por-espet…’) #1 /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(”, Array) #2 /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-content/plugins/woocommerce/includes/wc-attribute-functions.php(520): do_action(‘woocommerce_att…’, 387, Array, ‘carne-por-espet…’) #4 /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-content/plugins/woocommerce/includes/wc-attribute-functions.php(607): wc_create_attribute(Array) #5 /home/222535.cloudwaysapps.com/wm in /home/222535.cloudwaysapps.com/wmwmqusqsy/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php on line 22
December 3, 2018 at 5:30 pm #93483
Artem TemosKeymasterHi,
Please, describe to us your problems in a bit more details. Attach some screenshots and provide us with a list of steps on how to reproduce it on your website. We will need your admin and FTP access to check this as well.
Thank you in advance.
December 3, 2018 at 5:56 pm #93495
jcmachadoParticipantThank you for the response.
Well, I have a program which uses the WooCommerce REST API in order to create products, its attributes and other product data from my ERP. Its simply uses http requests as documented by the API. I’m having a problem specifically when I try to update product attributes.
When I try a PUT request in wp-json/wc/v2/products/attributes/id endpoint, I end receiving the “Uncaught Error: Call to undefined function woodmart_admin_scripts_localize()” error.
Can you test the request using Postman (https://www.getpostman.com) app or ARC Chrome Extension? The instructions are below.
Attachments:
You must be logged in to view attached files.December 4, 2018 at 6:59 am #93557
Artem TemosKeymasterHi,
We need your admin access also. Be sure that you don’t have any extra plugins installed and don’t use a child theme.
Regards
December 4, 2018 at 10:20 am #93663
jcmachadoParticipantWell, I do have some extra plugins, in order to support all my online store needs. But I think is somewhat related to Woodstore Theme (hence the error message) and because I tested the same process in my old store, with the same plugins but using Storefront theme.
Tha admin accessa credentials are provided below.
December 4, 2018 at 12:15 pm #93687
Artem TemosKeymasterAnyway, we need to disable them to be able to check without a plugin. If you can’t do this on your live website, we suggest you create a development copy where you can do such experiments.
December 4, 2018 at 4:19 pm #93833
jcmachadoParticipantWe can do this in our current live site. Just e-mail me, please, during your access so I can be aware of any inconsistency.
Can you e-mail me at the beginning and the end of your interaction?
December 5, 2018 at 7:05 am #93941
Artem TemosKeymasterHi,
We just checked it but there are two problems: we can’t connect to your server with the FTP you provided and we don’t see errors, just 500 Internal Server Error.
December 5, 2018 at 11:38 am #94025
jcmachadoParticipantHello!
In order to get the described error message instead of the simple error 500 message, you have to enable the
define('WP_DEBUG', false);
directive in wp-config.php file. I leave it as false to prevent unwanted error messages displayed to the users.If you succeed in accessing the FTP, can you set it to true to test and then set it back to false, please?
Are you trying to access by FTP or SFTP? Can you send me your IP so I can whitelist it?
Thanks.
December 5, 2018 at 12:21 pm #94036
Artem TemosKeymasterTry to add the following PHP code snippet to the child theme functions.php file to fix this
add_action( 'woocommerce_attribute_updated', 'woodmart_wc_attribute_update', 20, 3); function woodmart_wc_attribute_update( $attribute_id, $attribute, $old_attribute_name ) { update_option( 'woodmart_pa_' . $attribute['attribute_name'] . '_swatch_size', $_POST['attribute_swatch_size'] ); update_option( 'woodmart_pa_' . $attribute['attribute_name'] . '_show_on_product', $_POST['attribute_show_on_product'] ); // Change value of selected option if( function_exists( 'woodmart_admin_scripts_localize' ) ) woodmart_admin_scripts_localize(); }
December 5, 2018 at 5:15 pm #94128
jcmachadoParticipantApparently, everything is working fine!
Thank you very much!December 5, 2018 at 6:34 pm #94162
Artem TemosKeymasterYou are welcome.
-
AuthorPosts
The topic ‘Problem with REST API (PUT in products/attributes)’ is closed to new replies.
- You must be logged in to create new topics. Login / Register