Home Forums WoodMart support forum Problem with REST API (PUT in products/attributes – ERP. JTL, BigBuy)

Problem with REST API (PUT in products/attributes – ERP. JTL, BigBuy)

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #276049

    WebGuide
    Participant

    Hello Xtemos-Team,

    as described here in this post I have exactly the same problem.
    https://xtemos.com/forums/topic/problem-with-rest-api-put-in-products-attributes/

    No data can be loaded into WordPress via my ERP system.

    There are a lot of posts here on this forum that have struggled with this problem and almost always no solution has been found, even from you offers that you get your money back. This affects all ERP, Bigbuy and JTL users that I have seen here in the forum and hope we can solve the whole thing here.

    I use JTL ERP system
    https://www.jtl-software.de

    And for that this interface/connector
    https://www.jtl-software.de/anbindung-shopsysteme/woocommerce

    In the article “Problem with REST API (PUT in products/attributes)” from “jcmachado” a code snippet is offered as a solution

    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();
    }

    This snippet has probably not only helped with “jcmachado” but also some JTL users have been able to use this snippet successfully. This is evident from some JTL forum posts such as here.
    https://forum.jtl-software.de/threads/online-shop-abgleich-woocommerce-bilder-werden-nicht-importiert.130787/

    Unfortunately, this snippet no longer works and I get a crash of my entire WordPress page every time. It is probably no longer up to date. Here is the log from my ERP system (JTL Wawi)

    Exception: Call to undefined function woodmart_admin_scripts_localize()
    Call to undefined function woodmart_admin_scripts_localize()
    Merkmale-Senden-Fehler: Bitte beachten Sie, dass zur Fehler-Diagnose ebenfalls die Log-Datei des Servers und das Abgleich-Log der JTL-Wawi notwendig sind!
    Exception bei specific.push: Call to undefined function woodmart_admin_scripts_localize()
    
    Call to undefined function woodmart_admin_scripts_localize()
    
    Response: {"result":null,"error":{"code":0,"message":"Call to undefined function woodmart_admin_scripts_localize()","data":"Exception 'Error' (Code: 0) with message 'Call to undefined function woodmart_admin_scripts_localize()' in \/wp-content\/themes\/woodmart\/inc\/integrations\/woocommerce\/modules\/attributes-meta-boxes.php:23"},"jtlrpc":"2.0","id":"unknown"}
    Exception bei specific.push: Call to undefined function woodmart_admin_scripts_localize()
    
    Call to undefined function woodmart_admin_scripts_localize()
    
    Response: {"result":null,"error":{"code":0,"message":"Call to undefined function woodmart_admin_scripts_localize()","data":"Exception 'Error' (Code: 0) with message 'Call to undefined function woodmart_admin_scripts_localize()' in \/wp-content\/themes\/woodmart\/inc\/integrations\/woocommerce\/modules\/attributes-meta-boxes.php:23"},"jtlrpc":"2.0","id":"unknown"}

    Sounds like “attributes-meta-boxes” is one of the problems!

    In the JTL forum you can also read again and again from moderators and developers that the cause of this error is your theme’s own built-in caching.

    Can you please update this snippet and adapt to the current conditions.

    And / or also tell me how to turn off theme’s own cache 100% to prevent this error, then I would test this and confirm here

    Also in the future in the Woodmart core a function to build or note that when chaching is active the file transfer from an ERP system does not work. I think this hits here many users who work with an ERP system / dropshipping system!

    You are even known at JTL with this problem so that you are listed under the list “Incompatible with these plugins”. See screenshot. 😀

    Thank you in advance and I hope we can find a permanent solution to this problem. Not that the next update the fun starts all over again. THANKS!

    Best Regards

    Attachments:
    You must be logged in to view attached files.
    #276064

    Artem Temos
    Keymaster

    Hello,

    Thank you for contacting us.

    Could you please send us a screenshot of where you placed the code? Also, provide us your admin and FTP access and describe the steps to reproduce this error on your website.

    Kind Regards

    #276071

    WebGuide
    Participant

    I had it like here in the ticket https://xtemos.com/forums/topic/problem-with-rest-api-put-in-products-attributes/ inserted as described under child theme functions.php

    that did not work, but I found the solution!

    at

    /wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php

    In line 23 at
    // Change value of selected option
    if( function_exists( 'woodmart_admin_scripts_localize' ) )

    will look like this.

    if( ! function_exists( 'woodmart_wc_attribute_update' ) ) {
    	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', sanitize_text_field( $_POST['attribute_swatch_size'] ) );
    
    		$attribute_show_on_product = isset( $_POST['attribute_show_on_product'] ) ? $_POST['attribute_show_on_product'] : '';
    		update_option( 'woodmart_pa_' . $attribute['attribute_name'] . '_show_on_product', sanitize_text_field( $attribute_show_on_product ) );
    
    		// Change value of selected option
    		if( function_exists( 'woodmart_admin_scripts_localize' ) )
    		woodmart_admin_scripts_localize();
    	}
    }

    For now it works, but the developers of JTL say not without reason that your caching makes a problem, how can I disable this completely? Should further errors occur I will want to test this!

    #276186

    Artem Temos
    Keymaster

    Hello,

    Thank you for sharing your solution here.

    Could you please specify what caching you mean? Maybe you have some examples from our theme code.

    Kind Regards

    #277613

    WebGuide
    Participant

    Hello,

    Could you please specify what caching you mean? Maybe you have some examples from our theme code.

    -I have no idea, in the JTL forum this was mentioned many times.

    The fix as described above in the file attributes-meta-boxes.php has fixed the error code from the ERP system. But the system still does not work properly. The properties (characteristics/attributes) are not all transferred.

    The following always appears in the log of the connector

    [2021-03-29 18:50:05] global.NOTICE: (E_NOTICE) File (/htdocs/clickandbuilds/Beta322411/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php, 17): Undefined index: attribute_swatch_size [] []
    [2021-03-29 18:51:36] global.NOTICE: (E_NOTICE) File (/htdocs/clickandbuilds/Beta322411/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php, 36): Undefined index: attribute_swatch_size [] []

    What exactly is “attribute_swatch_size” responsible for? Where is what displayed? It’s about attributes already clear 😀

    It looks like I have to say goodbye to your theme, which is actually not like it because I like it very much but if the transfer of products is not possible because of special features and I have no way to disable or solve it wass that. JTL itself as shown above that it is not compatible with you.

    Hopefully you can help.

    #277758

    Artem Temos
    Keymaster

    Hello,

    This code is responsible for our theme custom options for product attributes. These attributes can be found here http://prntscr.com/110jogk
    It has no connection to any kind of cache. If you want to disable this functionality completely, add the following code snippet to the child theme and test how it wroks.

    function woodmart_wc_attribute_update( $attribute_id, $attribute, $old_attribute_name ) {}

    Kind Regards

    #278475

    WebGuide
    Participant

    I have pasted the code in my function.php of my child theme below.

    now I have not only line 17 and 36 as error but still 35 😀

    That’s all the errors now!

    global.NOTICE: (E_NOTICE) File (/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php, 17): Undefined index: attribute_swatch_size [] []
    global.NOTICE: (E_NOTICE) File (/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php, 35): Undefined index: attribute_swatch_size [] []
    global.NOTICE: (E_NOTICE) File (/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php, 36): Undefined index: attribute_swatch_size [] []

    Until now I had always edited the attributes-meta-boxes.php file in my main theme. Now I have created the following structure in my child theme.
    child-theme\inc\integrations\woocommerce\modules\attributes-meta-boxes.php

    Works without problems, but the bug is still not solved.
    The error manifests itself in such a way that sometimes the product properties (for example color, material or brand) are not transferred and / or not assigned.

    here the code from my attributes-meta-boxes.php

    <?php if ( ! defined('WOODMART_THEME_DIR')) exit('No direct script access allowed');
    
    /**
     * ------------------------------------------------------------------------------------------------
     * Add meta boxes to attributes interface for woocommerce
     * ------------------------------------------------------------------------------------------------
     */
    
    /**
     * ------------------------------------------------------------------------------------------------
     * Handle edit attribute action
     * ------------------------------------------------------------------------------------------------
     */
    if( ! function_exists( 'woodmart_wc_attribute_update' ) ) {
    	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', sanitize_text_field( $_POST['attribute_swatch_size'] ) );
    
    		$attribute_show_on_product = isset( $_POST['attribute_show_on_product'] ) ? $_POST['attribute_show_on_product'] : '';
    		update_option( 'woodmart_pa_' . $attribute['attribute_name'] . '_show_on_product', sanitize_text_field( $attribute_show_on_product ) );
    
    		// Change value of selected option
    		if( function_exists( 'woodmart_admin_scripts_localize' ) )
    		woodmart_admin_scripts_localize();
    	}
    }
    
    /**
     * ------------------------------------------------------------------------------------------------
     * Handle add attribute action
     * ------------------------------------------------------------------------------------------------
     */
    if( ! function_exists( 'woodmart_wc_attribute_add' ) ) {
    	add_action( 'woocommerce_attribute_added', 'woodmart_wc_attribute_add', 20, 2);
    	function woodmart_wc_attribute_add( $attribute_id, $attribute ) {
    		add_option( 'woodmart_pa_' . $attribute['attribute_name'] . '_swatch_size', sanitize_text_field( $_POST['attribute_swatch_size'] ) );
    
    		$attribute_show_on_product = isset( $_POST['attribute_show_on_product'] ) ? $_POST['attribute_show_on_product'] : '';
    		add_option( 'woodmart_pa_' . $attribute['attribute_name'] . '_show_on_product', sanitize_text_field( $attribute_show_on_product ) );
    		
    		// Change value of selected option
    		if( function_exists( 'woodmart_admin_scripts_localize' ) )
    		woodmart_admin_scripts_localize();
    	}
    }
    
    /**
     * ------------------------------------------------------------------------------------------------
     * Get attribute term function
     * ------------------------------------------------------------------------------------------------
     */
    if( ! function_exists( 'woodmart_wc_get_attribute_term' ) ) {
    	function woodmart_wc_get_attribute_term( $attribute_name, $term ) {
    		return get_option( 'woodmart_' . $attribute_name . '_' .$term );
    	}
    }

    here is the developer doc for the connector.
    https://jtl-devguide.readthedocs.io/projects/jtl-connector/en/master/

    There are many users who have expressed problems in the JTL forum and use your theme, if you can solve the problem sustainably you will certainly get more German users. Currently you are also on the ban list as incompatible plugin/theme.

    In the attachment I have packed the connector log for you, maybe this will help you

    Best regards

    #278492

    WebGuide
    Participant

    There is an error when you put the code in the functions.php of the child theme… but was hidden and came only spontaneously

    
    Fatal error: Cannot redeclare woodmart_wc_attribute_update() (previously declared in /wp-content/themes/woodmart/inc/integrations/woocommerce/modules/attributes-meta-boxes.php:16) in /wp-content/themes/woodmart-child/functions.php on line 48
    #278848

    Artem Temos
    Keymaster

    Hello,

    Strange, but we can’t reproduce the error on our side. Could you please provide us your admin and FTP access so we can check?

    Kind Regards

    #302889

    kendesign
    Participant

    Dear XTEMOS Team, we purchased 6 Woodmart Licences in the past 2 years.
    We further have at least a dozen Woocommerce-Shops to relaunch and wanted to continue purchasing Woodmart licences for each, since we know this is the best WC Theme out there. We really Love your Theme.

    But we did not know, that Woodmart would be the only theme out there, having Problems with JTL-Connector. JTL is an extreme desired Business-ERP for many businesses, it handles the whole merchandise management on many platforms like Amazon, ebay and offers important and very useful central ERP-Functions.

    We just connected one Woodmart-Shop to JTL like @OneM8 tried but we can’t get Product-Photos syncing, for sure the same issues OneM8 had.

    Could you please post the solution of your support for this case?
    Did you solve the Problem?

    This will be the decision-point for us, if we should continue with further Woodmart Licences or switch to another theme, since compatibility with JTL is not only very important, more and more existing and new customers ask straight for building webshops with Connection to JTL Wawi.

    Kind Regards
    Fatih

    #302981

    Artem Temos
    Keymaster

    Hello @kendesign,

    Thank you very much for choosing our theme for your project.

    We would be happy to help with this issue. Please, create a separate topic and describe this issue in more detail. Provide us your admin and FTP access so we can check and try to fix it.

    Kind Regards

Viewing 11 posts - 1 through 11 (of 11 total)