Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Weird variations behavior: duplicates #430

Closed
dancs2520 opened this issue Jun 10, 2019 · 18 comments
Closed

Weird variations behavior: duplicates #430

dancs2520 opened this issue Jun 10, 2019 · 18 comments

Comments

@dancs2520
Copy link

dancs2520 commented Jun 10, 2019

I have some products with variations. Among such variations, some are not "Enabled" at this moment. When I go to the edit page of a product in the second language (JP), I see that every one of the "disabled" variations appears quadruplicated. For example: I have S, M, L, XL sizes, and S and XL are not enabled. In the JP version, I see S, S, S, S, M, L, XL, XL, XL, XL.

notes: 1) if I click Update, even more extra variations appear;
2) I can remove the extras, as long as I don't Update;
3) This happens only with the disabled variations;
4) all the extras share the same SKU
5) the problem appears to somehow be similar to #418
6) I have tried fresh with new products and the problem persist

What product versions and settings are you using when this issue occurs?

  • PHP: 7.1
  • WordPress: 5.2.1
  • WooCommerce: 3.6.4
  • Polylang: 2.5.4
  • Hyyan WooCommerce Polylang Integration: 1.3.0
  • Browser: Google Chrome

Steps to Reproduce

  1. Create new product in primary language (EN) with variations, some of them not enabled
  2. Add the new page with secondary language
  3. Check variations and see that there are extras in there

What I Expected

That the variations appear like in the case with Enabled products, just one per original variation.
Also, that the Update button don't aggravate the problem

What Happened Instead

I am getting many extra variations

Copy and paste the system status report from WooCommerce > System Status in WordPress admin here.


WordPress environment
WordPress address (URL):		https://tokyodirect.jp
Site address (URL):		https://tokyodirect.jp
WooCommerce version:		3.6.4
Log directory writable:		 /home/v7dc1m2mjuf0/public_html/wp-content/uploads/wc-logs/
WordPress version:		5.2.1
WordPress multisite:		–
WordPress memory limit:		256 MB
WordPress debug mode:		–
WordPress cron:		
Language:		en
External object cache:		–
Server environment
Server info:		Apache
PHP version:		7.1.28 - We recommend using PHP version 7.2 or above for greater performance and security. How to update your PHP version
PHP post max size:		32 MB
PHP time limit:		30
PHP max input vars:		1000
cURL version:		7.62.0, OpenSSL/1.0.2k
SUHOSIN installed:		–
MySQL version:		5.6.43-cll-lve
Max upload size:		32 MB
Default timezone is UTC:		
fsockopen/cURL:		
SoapClient:		
DOMDocument:		
GZip:		
Multibyte string:		
Remote post:		
Remote get:		
Database
WooCommerce database version:		3.6.4
Database prefix	 	wp_
MaxMind GeoIP database:		 /home/v7dc1m2mjuf0/public_html/wp-content/uploads/GeoLite2-Country.mmdb
Total Database Size	 	8.24MB
Database Data Size	 	6.93MB
Database Index Size	 	1.31MB
wp_woocommerce_sessions	 	Data: 0.89MB + Index: 0.06MB
wp_woocommerce_api_keys	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_attribute_taxonomies	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_downloadable_product_permissions	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_order_items	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_order_itemmeta	 	Data: 0.01MB + Index: 0.01MB
wp_woocommerce_tax_rates	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_tax_rate_locations	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_shipping_zones	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_shipping_zone_locations	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_shipping_zone_methods	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_payment_tokens	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_payment_tokenmeta	 	Data: 0.00MB + Index: 0.00MB
wp_woocommerce_log	 	Data: 0.00MB + Index: 0.00MB
wp_commentmeta	 	Data: 0.00MB + Index: 0.01MB
wp_comments	 	Data: 0.02MB + Index: 0.02MB
wp_links	 	Data: 0.00MB + Index: 0.00MB
wp_newsletter	 	Data: 0.00MB + Index: 0.01MB
wp_newsletter_emails	 	Data: 0.00MB + Index: 0.00MB
wp_newsletter_sent	 	Data: 0.00MB + Index: 0.00MB
wp_newsletter_stats	 	Data: 0.00MB + Index: 0.00MB
wp_newsletter_user_logs	 	Data: 0.00MB + Index: 0.00MB
wp_nf3_actions	 	Data: 0.00MB + Index: 0.00MB
wp_nf3_action_meta	 	Data: 0.03MB + Index: 0.01MB
wp_nf3_chunks	 	Data: 0.00MB + Index: 0.00MB
wp_nf3_fields	 	Data: 0.00MB + Index: 0.00MB
wp_nf3_field_meta	 	Data: 0.09MB + Index: 0.01MB
wp_nf3_forms	 	Data: 0.00MB + Index: 0.00MB
wp_nf3_form_meta	 	Data: 0.03MB + Index: 0.01MB
wp_nf3_objects	 	Data: 0.00MB + Index: 0.00MB
wp_nf3_object_meta	 	Data: 0.00MB + Index: 0.00MB
wp_nf3_relationships	 	Data: 0.00MB + Index: 0.00MB
wp_nf3_upgrades	 	Data: 0.07MB + Index: 0.00MB
wp_ngg_album	 	Data: 0.00MB + Index: 0.00MB
wp_ngg_gallery	 	Data: 0.00MB + Index: 0.00MB
wp_ngg_pictures	 	Data: 0.00MB + Index: 0.00MB
wp_options	 	Data: 1.82MB + Index: 0.08MB
wp_postmeta	 	Data: 2.24MB + Index: 0.77MB
wp_posts	 	Data: 1.56MB + Index: 0.14MB
wp_redirection_404	 	Data: 0.00MB + Index: 0.00MB
wp_redirection_groups	 	Data: 0.00MB + Index: 0.00MB
wp_redirection_items	 	Data: 0.00MB + Index: 0.02MB
wp_redirection_logs	 	Data: 0.00MB + Index: 0.00MB
wp_termmeta	 	Data: 0.00MB + Index: 0.01MB
wp_terms	 	Data: 0.01MB + Index: 0.02MB
wp_term_relationships	 	Data: 0.03MB + Index: 0.07MB
wp_term_taxonomy	 	Data: 0.01MB + Index: 0.01MB
wp_totalsoft_new_plugin	 	Data: 0.00MB + Index: 0.00MB
wp_totalsoft_portfolio_albums	 	Data: 0.00MB + Index: 0.00MB
wp_totalsoft_portfolio_dbt	 	Data: 0.00MB + Index: 0.00MB
wp_totalsoft_portfolio_dbt_1	 	Data: 0.01MB + Index: 0.00MB
wp_totalsoft_portfolio_dbt_2	 	Data: 0.00MB + Index: 0.00MB
wp_totalsoft_portfolio_dbt_3	 	Data: 0.00MB + Index: 0.00MB
wp_totalsoft_portfolio_dbt_4	 	Data: 0.00MB + Index: 0.00MB
wp_totalsoft_portfolio_id	 	Data: 0.00MB + Index: 0.00MB
wp_totalsoft_portfolio_images	 	Data: 0.00MB + Index: 0.00MB
wp_totalsoft_portfolio_manager	 	Data: 0.00MB + Index: 0.00MB
wp_usermeta	 	Data: 0.10MB + Index: 0.02MB
wp_users	 	Data: 0.00MB + Index: 0.01MB
wp_wc_download_log	 	Data: 0.00MB + Index: 0.00MB
wp_wc_product_meta_lookup	 	Data: 0.01MB + Index: 0.02MB
wp_wc_webhooks	 	Data: 0.00MB + Index: 0.00MB
Post Type Counts
attachment	 	243
custom_css	 	1
is_search_form	 	1
jetpack_migration	 	2
jp_img_sitemap	 	1
jp_sitemap	 	1
jp_sitemap_master	 	1
nav_menu_item	 	28
nf_sub	 	9
page	 	28
polylang_mo	 	2
portfolio	 	19
post	 	10
product	 	16
product_variation	 	376
revision	 	397
scheduled-action	 	5
shop_order	 	4
woocarousel	 	1
wp_block	 	4
wpcf7_contact_form	 	1
Security
Secure connection (HTTPS):		
Hide errors from visitors		
Active plugins (26)
Polylang	 	by Frédéric Demarle – 2.5.4
Ivory Search	 	by Ivory Search – 4.2.1
Contact Widgets	 	by GoDaddy – 1.6.2
Enhanced Media Library	 	by wpUXsolutions – 2.7.2
Insert Headers and Footers	 	by WPBeginner – 1.4.4
Kadence Blocks - Gutenberg Page Builder Toolkit	 	by Kadence Themes – 1.5.6
Kadence Importer	 	by Kadence Themes – 2.0.5
Limit Login Attempts Reloaded	 	by WPChef – 2.8.1
Newsletter	 	by Stefano Lissa & The Newsletter Team – 6.0.6
Ninja Forms	 	by The WP Ninjas – 3.4.13
WooCommerce Product Carousel Slider	 	by AazzTech – 3.3.2 – Not tested with the active version of WooCommerce
Redirection	 	by John Godley – 4.3.1
Page Builder by SiteOrigin	 	by SiteOrigin – 2.10.5
SiteOrigin Widgets Bundle	 	by SiteOrigin – 1.15.7
Under Construction	 	by WebFactory Ltd – 3.45
Kadence Toolkit	 	by Kadence Themes – 4.9.2
Visual Portfolio	 	by nK – 1.12.0
WooCommerce Weight Based Shipping	 	by weightbasedshipping.com – 5.2.6
WooCommerce Blocks	 	by Automattic – 2.1.0
Hyyan WooCommerce Polylang Integration	 	by Hyyan Abo Fakher – 1.3.0 – Not tested with the active version of WooCommerce
WooCommerce For Japan	 	by Artisan Workshop – 1.2.27
WooCommerce PayPal Checkout Gateway	 	by WooCommerce – 1.6.14
WooCommerce Stripe Gateway	 	by WooCommerce – 4.2.0
WooCommerce Services	 	by Automattic – 1.20.0
WooCommerce	 	by Automattic – 3.6.4
YITH Pre-Order for WooCommerce	 	by YITH – 1.1.8
Inactive plugins (9)
Akismet Anti-Spam	 	by Automattic – 4.1.2
Classic Editor	 	by WordPress Contributors – 1.5
Contact Form 7	 	by Takayuki Miyoshi – 5.1.3
Gallery Portfolio	 	by Total-Soft – 1.3.0
GoDaddy Email Marketing	 	by GoDaddy – 1.4.2
Jetpack by WordPress.com	 	by Automattic – 7.4
Lingotek Translation	 	by Lingotek and Frédéric Demarle – 1.4.2
WP BASIC Auth	 	by wokamoto – 1.1.3
WP Mail SMTP	 	by WPForms – 1.4.2
Settings
API enabled:		–
Force SSL:		–
Currency		USD ($)
Currency position		left
Thousand separator		,
Decimal separator		.
Number of decimals		2
Taxonomies: Product types		external (external), grouped (grouped), simple (simple), variable (variable)
Taxonomies: Product visibility		exclude-from-catalog (exclude-from-catalog), exclude-from-search (exclude-from-search), featured (featured), outofstock (outofstock), rated-1 (rated-1), rated-2 (rated-2), rated-3 (rated-3), rated-4 (rated-4), rated-5 (rated-5)
Connected to WooCommerce.com:		–
WooCommerce pages
Shop base:		#815 - /shop/
Cart:		#816 - /cart/
Checkout:		#6 - /checkout/
My account:		#7 - /my-account/
Terms and conditions:		#3645 - /terms-and-conditions/
Theme
Name:		Virtue
Version:		3.3.4
Author URL:		https://kadencethemes.com/
Child theme:		 – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
WooCommerce support:		
Templates
Overrides	 	virtue/woocommerce/archive-product.php, 
virtue/woocommerce/content-product.php, 
virtue/woocommerce/content-product_cat.php, 
virtue/woocommerce/content-single-product.php, 
virtue/woocommerce/loop/loop-end.php, 
virtue/woocommerce/loop/loop-start.php, 
virtue/woocommerce/loop/price.php, 
virtue/woocommerce/loop/rating.php, 
virtue/woocommerce/loop/sale-flash.php, 
virtue/woocommerce/single-product/add-to-cart/external.php, 
virtue/woocommerce/single-product/add-to-cart/grouped.php, 
virtue/woocommerce/single-product/add-to-cart/simple.php, 
virtue/woocommerce/single-product/add-to-cart/variable.php, 
virtue/woocommerce/single-product/price.php, 
virtue/woocommerce/single-product/product-image.php, 
virtue/woocommerce/single-product/product-thumbnails.php, 
virtue/woocommerce/single-product/sale-flash.php, 
virtue/woocommerce/single-product.php, 
virtue/woocommerce/taxonomy-product_cat.php, 
virtue/woocommerce/taxonomy-product_tag.php
Action Scheduler
Action Status	 	Count	Oldest Scheduled Date	Newest Scheduled Date
Complete	 	4	2019-05-16 13:00:00 +0000	2019-06-06 13:38:07 +0000
Pending	 	1	2019-06-13 13:38:08 +0000	2019-06-13 13:38:08 +0000
Canceled	 	0	–	–
In-progress	 	0	–	–
Failed	 	0	–	–


@Jon007
Copy link
Contributor

Jon007 commented Jun 11, 2019

@dancs2520
Wow!
I confess I never noticed it was possible to disable variations!! And Why?? Most people remove them or put them out of stock.

A couple of things first:

  1. version 1.3 of this plugin is not compatible with WooCommerce 3.6+ for other reasons so it might be worth trying the latest releases from github which address 3.6 issues: https://github.com/hyyan/woo-poly-integration/releases
  2. I cannot reproduce this with this plugin v1.4.1 and WooCommerce 3.6.4 : if you still have problems with v1.4.1 can you try it with other plugins turned off? (apart from WooCommerce and Polylang).
    In the case of the other issue you refer to, there were various other plugins enabled which might well hook into the post saving process such as Duplicate Page and Duplicator

I do notice that disabling a variation doesn't synchronise the disabled property and we don't have an option for that, but as per my initial comment, no one has raised that before...

@Jon007
Copy link
Contributor

Jon007 commented Jun 11, 2019

Ok I have reproduced this.
(It doesn't reproduce with an attribute created directly at the product but does with an attribute created in Products, Attributes)

@dancs2520
Copy link
Author

@Jon007, since I already had the attribute created, I didn't even tried to reproduce the issue with a new one created directly from the products.. Sorry about that.
You did it on 1.4.1 and WC 3.6.4, right? Thank you for looking into that..

Ps.: the reason we have this variation disabled is that we have some products in stock, but we still can't sell them due to some legal issues.. We plan to just enable them as soon as such issues are solved.

@Jon007
Copy link
Contributor

Jon007 commented Jun 11, 2019

Enabled isn't currently compatible with with plugin's copying of variation meta because there is no 'Enabled' meta, instead it is saved directly as the post status of the variation, as per the woocommerce implementation:

'status'            => isset( $_POST['variable_enabled'][ $i ] ) ? 'publish' : 'private',

Since the posts are private, calls like get_posts() used in Variation.php to find the translated variations will fail, because get_posts() adds an implied filter for only published posts, unless another status is specifically requested: a fix may well be to add 'post_status' => 'any' to these queries.

@Jon007 Jon007 closed this as completed in 7c475b8 Jun 11, 2019
@Jon007
Copy link
Contributor

Jon007 commented Jun 11, 2019

@dancs2520 , I have checked in a fix which is limited to the Variation.php file - if in doubt just use this version of the Variation.php file.
This synchronises the 'Enabled' status between languages as well as avoiding the excessive duplications.

There is not an option to not synchronise the Enabled status, and if needed that would need to be logged as a separate issue for enhancement request which would need some thought as to what happens in the shopping cart etc if you change languages whilst shopping... (by default, if the translation is not available in target language, the original language would be shown, items are not removed from the basket due to missing or unavailable translations).

@AntonGrekov
Copy link

AntonGrekov commented Apr 16, 2020

I am sorry to write here, but i got similar problem with variation duplication for variable products.
For newly created variable products it works fine. But for our product base that was created before plugin installation all described by TS duplicate issues occur.
So, the Issue is in variation duplication for translated product(the one with locked edit fields). WooPoly version is 1.4.3, WooCommerce 3.8.1 and WP is 5.2.5

I tried creating translated product via 3 ways:

  1. Duplicate it via Duplicate plugin , then change product label and assign it via PolyLang input field
  2. Press on '+' to add a new language translation for product
  3. Create completly new product and link it via PolyLang input field

In all 3 ways , product variations in translated product are doubled. On original product i have 5-7 attributes, only 1 of them is used for variations(it has 2 values), so variations are only two, on translated product - 4

If i open original product and click update - it double all variations for translated product - makes it 8 - 16 - 32 etc

@AmrSubZero
Copy link

I am sorry to write here, but i got similar problem with variation duplication for variable products.
For newly created variable products it works fine. But for our product base that was created before plugin installation all described by TS duplicate issues occur.
So, the Issue is in variation duplication for translated product(the one with locked edit fields). WooPoly version is 1.4.3, WooCommerce 3.8.1 and WP is 5.2.5

I tried creating translated product via 3 ways:

  1. Duplicate it via Duplicate plugin , then change product label and assign it via PolyLang input field
  2. Press on '+' to add a new language translation for product
  3. Create completly new product and link it via PolyLang input field

In all 3 ways , product variations in translated product are doubled. On original product i have 5-7 attributes, only 1 of them is used for variations(it has 2 values), so variations are only two, on translated product - 4

If i open original product and click update - it double all variations for translated product - makes it 8 - 16 - 32 etc

Same.

As i click update on the product in other language it duplicates the variation attributes. it doubles it eveytime i update the product.

#478

@Jon007
Copy link
Contributor

Jon007 commented Jan 30, 2021

confirmed, the fix is no longer working with latest plugin and wp versions

@Jon007 Jon007 reopened this Jan 30, 2021
@Jon007
Copy link
Contributor

Jon007 commented Jan 31, 2021

get_posts() in variation.php duplicate() doesn't work because the query is hooked by Polylang such that translated variations are never found: Polylang add a wp query filter by language on the 'wrong' language for this context, besides which this plugin never used to assign language to the variations only the parent variable product.

Since no translation is found the code creates new translated variations as often as it is called.
The code is also called too often for various other reasons.

Other instances of variation lookups were switched to use getRelatedVariation() which avoids the polylang hooks by avoiding wp_query in favour of more direct query for all related variations (independently of language).

This can also be addressed by adding 'lang' => '', to the wp query parameters, Polylang allows this as a way of querying across languages.

@charalampospapadop
Copy link

Hello, i have the same problem.I have main language(greek) and secondary(english) set on my shop. Every time i update a product, it duplicates the secondary language product variations. Any solutions there?

@Jon007
Copy link
Contributor

Jon007 commented Feb 4, 2021

@charalampospapadop yes, these are the solutions checked in this week, please try from the latest source code if you can and report any issues with that.

@charalampospapadop
Copy link

@Jon007 Thank you for replying. By latest source code did u mean the Variation.php u shared if so i already tried that and it didnt work for me. I am on WordPress 5.3.4, WooCommerce 4.9.2 also got the latest versions of Hyyan and Polylang.

@Jon007
Copy link
Contributor

Jon007 commented Feb 5, 2021

@charalampospapadop there are also changes to variable.php and to the .js files in public/js
all of these are needed

@charalampospapadop
Copy link

@Jon007 Thanks a lot for the instructions, i am new to Github and sorry. Seems to work fine the only thing is that when i translate the product first time before i publish it , it does not show the variable products, then i publish it but they still wont show, i had to do 1 extra update after the publish, then they showed up. Thanks again.

@mkaramp
Copy link

mkaramp commented May 27, 2021

@Jon007 I have the same problem WP Version 5.7.2, Woocommerce Version 5.3.0, Polylang Version 3.0.4 , Hyyan Version 1.5.0.

@Jon007
Copy link
Contributor

Jon007 commented May 27, 2021

@mkaramp please try 1.5.1 as there were some significant corrections to the hooks used for synchronisation:
https://github.com/hyyan/woo-poly-integration/releases/tag/1.5.1
this has been in production use for a couple of weeks, once a few more people have tried it we'll ask Hyyan to push it to the wordpress plugins

@mkaramp
Copy link

mkaramp commented May 27, 2021

@Jon007 You re the best, problem solved. Thank you!

@Jon007
Copy link
Contributor

Jon007 commented May 30, 2021

@hyyan maybe we should release 1.5.1 to Wordpress.org

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants