hyyan / woo-poly-integration

Looking for maintainers! - Wordpress WooCommerce Polylang Integration
https://wordpress.org/plugins-wp/woo-poly-integration/
MIT License
183 stars 66 forks source link

Products disappear for the secondary language after out of stock #475

Closed Proxes-888 closed 3 years ago

Proxes-888 commented 4 years ago

Can you reproduce this issue on default Wordpress theme (eg Storefront)?

Yes

Can you reproduce this issue when all other plugins are disabled except WooCommerce, Polylang and Hyyan WooCommerce Polylang Integration?

Yes

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

Steps to Reproduce

Add a product with some stock quantity e.g. 5, save the product, create a second product for the secondary language. Later, set the stock quantity to 0 for the primary language, update the product, and set the stock for that product again to 5. The product re-appears only in the primary language - not in the secondary language.

What I Expected

I expect after changing the quantity of the product from 0 to positive number to make products in both languages appear in store.

What Happened Instead

Only product in primary language appeared

WordPress Environment

### WordPress Environment ### WordPress address (URL): http://localhost Site address (URL): http://localhost WC Version: 3.7.1 REST API Version: ✔ 1.0.2 Log Directory Writable: ✔ WP Version: 5.3 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: Apache/2.4.27 (Win64) PHP/7.3.12 PHP Version: 7.3.12 PHP Post Max Size: 8 MB PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: SUHOSIN Installed: – MySQL Version: ❌ 5.5.61 - We recommend a minimum MySQL version of 5.6. See: WordPress requirements Max Upload Size: 8 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ❌ Your server does not have the SoapClient class enabled - some gateway plugins which use SOAP may not work as expected. DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ❌ wp_remote_post() failed. Contact your hosting provider. Remote Get: ❌ wp_remote_get() failed. Contact your hosting provider. ### Database ### WC Database Version: 3.7.1 WC Database Prefix: wp_ MaxMind GeoIP Database: ✔ Total Database Size: 1.75MB Database Data Size: 0.77MB Database Index Size: 0.98MB wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_options: Data: 0.19MB + Index: 0.03MB + Engine InnoDB wp_postmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_posts: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB ### Security ### Secure connection (HTTPS): ❌ Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates. Hide errors from visitors: ✔ ### Active Plugins (3) ### Polylang: by WP SYNTEX – 2.6.7 Hyyan WooCommerce Polylang Integration: by Hyyan Abo Fakher – 1.4.3 – Not tested with the active version of WooCommerce WooCommerce: by Automattic – 3.7.1 – 3.8.0 is available ### Inactive Plugins (2) ### Akismet Anti-Spam: by Automattic – 4.1.3 Hello Dolly: by Matt Mullenweg – 1.7.2 ### Settings ### API Enabled: – Force SSL: – Currency: EUR (€) 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: – ### WC Pages ### Shop base: #6 - / Cart: #7 - /cart/ Checkout: #8 - /checkout/ My account: #9 - /my-account/ Terms and conditions: ❌ Page not set ### Theme ### Name: Storefront Child Version: 1.0.0 Author URL: http://orbicont.com Child Theme: ✔ Parent Theme Name: Storefront Parent Theme Version: 2.5.3 Parent Theme Author URL: https://woocommerce.com/ WooCommerce Support: ✔ ### Templates ### Overrides: – ### Action Scheduler ### Complete: 1 Oldest: 2019-11-25 23:24:12 +0000 Newest: 2019-11-25 23:24:12 +0000 Pending: 1 Oldest: 2019-11-26 23:24:12 +0000 Newest: 2019-11-26 23:24:12 +0000 Canceled: 1 Oldest: 2019-11-25 23:24:07 +0000 Newest: 2019-11-25 23:24:07 +0000 In-progress: 0 Oldest: – Newest: – Failed: 0 Oldest: – Newest: –
Jon007 commented 4 years ago

Hi, I am not quite clear which problem you are describing - are you managing stock separately in different languages? You say "The product re-appears only in the primary language - not in the secondary language." What is the stock level in the secondary language and what are you expecting it to be? Check that stock synchronisation is turned on in woopoly Features and Metas, see https://github.com/hyyan/woo-poly-integration/wiki/Stock and related pages on the wiki

Proxes-888 commented 4 years ago

Hi Jon, The stock synchronization is turned on. In the table wp_term_relationships the term outofstock is not cleared for the secondary language, when the stock quantity is changed from 0 to a positive number. It is cleared only for the primary language. Both products in the both languages show the same stock quantities in the backend. The quantity for the second language is not editable. The setting "Hide out of stock products" is checked in woocommerce, and the product in the second language does never reappear in the store. It appears, only if I manually clear the outofstock from the wp_term_relationships table.

Jon007 commented 4 years ago

ok this is reproduced with WooCommerce 4. the product comes back in stock but as you say does not appear in the catalogue pages. I was expecting this to be a cache issue or issue with the newish table eg wp_wc_product_meta_lookup but this seems updated successfully to instock on the translations once stock is restored. However as you say product_visibility is not synchronised and [only if Hide out of stock products is selected] will remain set to exclude-from-catalog, exclude-from-search and outofstock

Jon007 commented 3 years ago

when stock is managed at variation level, it appears that after a sale wp_postmeta _stock_status is set to outofstock even when stock has not yet reached zero. It then shows Out of stock in the admin products list at /wp-admin/edit.php?post_type=product and disappears from the catalogue although the product itself, if viewed, appears in stock and purchasable. wp_wc_product_meta_lookup and wp_postmeta are both out of sync between languages

Jon007 commented 3 years ago

options:

  1. action 'woocommerce_product_object_updated_props' could be used to sync the wp_wc_product_meta_lookup for translations but obviously both the underlying data and the lookup table need to be translated
  2. actions 'woocommerce_variation_set_stock_status' and 'woocommerce_product_set_stock_status' could be hooked in stock.php in the same way as done for 'woocommerce_product_set_stock' and 'woocommerce_variation_set_stock' but need to avoid saving the same product too many times or possible recursion
  3. SyncStock could check for discrepancy between actual stock level and stock status and reset stock status if needed

also possible bug: if stock is managed at the variation level, SyncStock uses Variation::getRelatedVariation( get_post_meta( $product_with_stock->get_id(), Variation::DUPLICATE_KEY, true ) That relies on the _point_to_variation meta linking secondary languages to the base language so should only work if the $product_with_stock is in the shop base language.