Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
Get the ID of the WooCommerce shop page with get_option('woocommerce_shop_page_id') on a translated page

Solution:

Our developers are checking the issue.

In the meantime I am suggesting you 2 workarounds.

1) Use

1
wc_get_page_id( 'shop' )
2) Go to woocommerce-multilingual/inc/class-wcml-store-pages.php around line 208

$addFilter = function( $slug ) use ( $convertPageId ) {
    add_filter( 'woocommerce_get_' . $slug . '_page_id', $convertPageId );
        };

and change into this :

$addFilter = function( $slug ) use ( $convertPageId ) {
        add_filter( 'woocommerce_get_' . $slug . '_page_id', $convertPageId );
        add_filter( 'option_woocommerce_' . $slug . '_page_id', $convertPageId );
        };

Relevant Documentation:

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: 

This topic contains 3 replies, has 2 voices.

Last updated by wimerH 1 year, 10 months ago.

Assisted by: Andreas.

Author Posts
March 6, 2023 at 10:30 am #13177477

wimerH

I am trying to:
Get the ID of the WooCommerce shop page with get_option('woocommerce_shop_page_id') on a translated page

I expected to see:
the ID of the WooCommerce shop page of the currently selected language
Instead, I got:
the ID of the shop page in the original language

Updating Woocommerce from 5.0.2 to 5.1 introduced this bug.

March 6, 2023 at 3:04 pm #13180551

Andreas

Hello there

Thank you for contacting us. I am happy to help you.

Indeed you are totally right. I have replicated the issue in a clean installation. I reported to our developers and now we need to wait for a reply.

I will update you when I am having news.

Regards,
Andreas

March 8, 2023 at 11:42 am #13198355

Andreas

Thank you for your time waiting for me.

Our developers are checking the issue.

In the meantime I am suggesting you 2 workarounds.

1) Use

wc_get_page_id( 'shop' )

2) Go to woocommerce-multilingual/inc/class-wcml-store-pages.php around line 208

$addFilter = function( $slug ) use ( $convertPageId ) {
	add_filter( 'woocommerce_get_' . $slug . '_page_id', $convertPageId );
		};

and change into this :

$addFilter = function( $slug ) use ( $convertPageId ) {
		add_filter( 'woocommerce_get_' . $slug . '_page_id', $convertPageId );
		add_filter( 'option_woocommerce_' . $slug . '_page_id', $convertPageId );
		};

I hope this helps. Please let us know how it goes or if you need any further assistance. I'll gladly help you. 🙂

Regards,
Andreas

March 10, 2023 at 2:05 pm #13218173

wimerH

Thanks Andreas, using this function works fine!