This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Tagged: Custom Work
This topic contains 23 replies, has 2 voices.
Last updated by Dražen 10 months, 3 weeks ago.
Assisted by: Dražen.
Author | Posts |
---|---|
January 19, 2024 at 2:39 pm #15205343 | |
nikolaosM |
Hello, We are trying to make a custom export of variable products + variations and, we came up with the error below. [19-Jan-2024 14:30:08 UTC] PHP Fatal error: Uncaught Error: Call to undefined method WP_Post::get_id() in /home/www/twomon/twomonkeys.gr/www/wp-content/plugins/woocommerce-multilingual/inc/class-wcml-wc-strings.php:103 The code we are using to get the variations as product objects is as below: $variationsIDs = $newProduct->get_children(); //returns array with variations ids How can we solve it? |
January 22, 2024 at 8:13 am #15209702 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, 1) I would advise updating to the latest WPML versions and making a backup. Please update all WPML plugins to the latest version by going to the Plugins → Add New page, click the Commercial tab, and then click Check for updates. - https://wpml.org/faq/install-wpml/#wpml-4-2-8 2) As for the error, it seems to be caused by your custom code. Please note we can not support or debug custom coding issues, as it would require checking all other parts of the code not only the one you shared, which is out of our scope. For custom coding service you can check WPML contractors: - https://wpml.org/contractors/ 3) In your case, what I suggest is getting the default product variation ID and then using the WPML object hook, to get the translated variation ID - https://wpml.org/wpml-hook/wpml_object_id/ 4) As for export I suggest using WP ALL Export: Regards, |
January 22, 2024 at 12:56 pm #15211407 | |
nikolaosM |
Hello again, At first the update didn't solve the problem. About the third answer you gave, we have to say that we are only querying the default language products (Greek) so we don't export their translation. So in the lines of our custom code that we have shared in the foreach loop we get only the default variation ID. We can understand that you can not provide support for custom coding problems, but the function we are using to get the variation based on its ID is a woocommerce function that is working properly for simple and variable products. Only in product variations we get this problem. We don't want to do the export with a plugin, because we want to export the product attributes and the free versions of export plugins do not provide that or if any of them provides it they only export simple products. That is why we came up with a custom code solution to export products in a csv file using simple PHP and woocommerce integrated functions. As you can see, we are not in need of any plugin. Thanks! |
January 22, 2024 at 1:16 pm #15211520 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, thanks for getting back. I created a minimal installation of WordPress, WPML, and all necessary WPML add-ons. You can access the WordPress dashboard using the link below: Kindly follow the steps below: Please try to not install any additional plugins or create a fully working website, 1 product and simple code would be enough to confirm if the issue happens. Let me know when done so I can check. Regards, |
January 22, 2024 at 4:27 pm #15212820 | |
nikolaosM |
We have added the content in the demo site as it is in our e-shop. We can not add custom coding because we need access to public_html folder. The way we are trying to export the products is by creating a file export-products.php in the public_html folder and we run it in the frontend. Please provide us with access to this filder or add this lines to a file in public_html flder. require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php'); //to be able to use woocommerce functions //get only greek published products $products = get_posts( array( foreach($products as $product){ if($newProduct->get_type() == 'variable'){ foreach($variationsIDs as $variationID){ The above code is supposed to return each variation as a product object. Thanks! |
January 22, 2024 at 4:43 pm #15212915 | |
nikolaosM |
Also we think that the problem is comming from this WCML_WC_Strings->translated_attribute_label('\xCE\x97\xCE\xBB\xCE\xB9\xCE\xBA\xCE\xAF\xCE\xB1', 'pa_ilikia', Object(WC_Product_Variation)). The sting insite the first quotes is decoded as "Ηλικία" witch is the Greek word for "Age" and we use it as the attribute name / label. Can you explain what this error means? |
January 23, 2024 at 7:34 am #15214244 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, as I already explained we can not debug such an issue as we need a full minimal environment, also whatever you have done has caused issues with the website and it is down. If you have a staging site, please share wp-admin and FTP and let me have a look there. I can not guarantee anything, but we will take a look. Let me know. Thanks, |
January 23, 2024 at 8:49 am #15214707 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, I am sorry but I can not check / debug on live website, not much I can do nor is it safe to check such issue on live website. Let's try again, but please do not add any additional theme or content. Just set up WPML WooCommerce and add a few dummy products manually, then using the file manager plugin add your code and test if the issue happens. We need to check and confirm issue happens in such a minimal environment without any additional plugins, etc. As said we need to confirm this is a WPML bug issue and not a custom code issue/plugin, as we can not support or debug custom coding issues. (https://wpml.org/purchase/support-policy/) Login link: hidden link Thanks, |
January 23, 2024 at 1:20 pm #15216902 | |
nikolaosM |
Well, we deactivated WPML Multilingual CMS and the export worked just fine. We used the code below to export the variations. $products = get_posts( array( foreach($products as $product){ if($newProduct->get_type() == 'variable'){ foreach($variationsIDs as $variationID){ So it is not a problem with the custom code. The problem is caused because of your plugin. We want to know why the plugin is not allowing product variations to be exported manually with code. Also as we asked before what is the meaning of this error WCML_WC_Strings->translated_attribute_label('\xCE\x97\xCE\xBB\xCE\xB9\xCE\xBA\xCE\xAF\xCE\xB1', 'pa_ilikia', Object(WC_Product_Variation)). |
January 23, 2024 at 1:25 pm #15216959 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, I understand, but I am not sure how should we help out if there is no way for us to check the issue and see what goes wrong and how. Also I can not know if any other part of your website is causing issue with our plugins. The only thing that I can see is that part of of error is saying that somewhere method is being called that doesn't exist (PHP Fatal error: Uncaught Error: Call to undefined method WP_Post::get_id), as I can see from information online there is no such method, for example: - https://wordpress.org/support/topic/fatal-error-related-to-wp_post-i-think-i-solved-it/ If you can help and reproduce the issue on shared test site, I can check further and consult with our 2nd tiers on this. Thanks, |
January 25, 2024 at 8:42 am #15224858 | |
nikolaosM |
We will try to create a demo site. We will need some time to do this since it is a verry big site. |
January 25, 2024 at 9:22 am #15225070 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, sure, take your time and let me know when done. Regards, |
January 30, 2024 at 10:30 am #15242648 | |
nikolaosM |
Hello again, the demo site is ready. Can you activate a private answer to send you the credentials? Thanks! |
January 30, 2024 at 10:37 am #15242673 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, sure, please also share step by step guide to check the issue. Regards, |
January 30, 2024 at 1:44 pm #15244123 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, you are using a lot of custom code and additional plugins, as I have said we need to confirm this in a simple dummy example. We can not debug your environment and custom code, that is not in our support policy. Please either reproduce the issue on the test site I provided before with a simple example code and 1 product or please disable all other plugins, leave active only WPML and WooCommerce ( I did this already) and use WP default theme. Simplify the code example so it shows an issue with 1 product example, we can not debug your whole code script and environment. Otherwise, I am afraid we can not help much and debug your custom-coded solution. Policy: https://wpml.org/purchase/support-policy/ Or hire WPML contractors for custom code issues: - https://wpml.org/contractors/ Regards, |