Skip Navigation

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.

This topic contains 24 replies, has 3 voices.

Last updated by Diego Pereira 1 year, 10 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
July 17, 2023 at 6:52 pm #14053115

mariaA-45

Tell us what you are trying to do?
My website uses WooCommerce and WooCommerce Memberships. Customers are enrolled in Memberships, when they purchase a corresponding product. I translated the WooCommerce product, the Membership plan and the page that the membership plan grants access to.

Now, when buying a membership product in the main language, the customer is enrolled in the corresponding membership (expected) and also enrolled in the translated membership (not necessarily expected).

The real problem is this though: when buying a *translated* membership product, the customer is *not* enrolled in any memberships (definitely not expected) and I can't figure out why.

Is there any documentation that you are following?
No, I can't find any.

Is there a similar example that we can see?
I can provide a Temporary Login Link for you to take a look. Staging also available.

What is the link to your site?
develobaby.com

July 18, 2023 at 9:16 am #14056873

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

Yes please provide the access to the staging site, as well as, the detailed steps to observe and understand the problem.

Please also deactivate all unnecessary plugins on the staging, so the issue can be reproduced with a minimal setup.

Remember to take full backup of the site beforehand.

I've set your next reply as private to provide the information safely.

Regards.

July 18, 2023 at 2:03 pm #14059903

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for providing the access.

I am working on this and 'll get back to you as soon as I find something or have a solution.

July 19, 2023 at 8:40 am #14063679

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience on this.

I tried the steps exactly you mentioned and found the issue.

But, then I deactivated all plugins except WPML's and WC's (see plugins page), switched to a standard WP theme 2023 and tried a few times and it seems to work just fine (see attached images).

Can you retry and see if you can reproduce the issue in current situation?

If not, then please try followings:

- Switch back to your theme and reproduce.
- Then continue to activate other plugins one by one and try to reproduce the issue.

This way we can see if another plugin or theme is causing this issue. Please let me know.

english.jpg
danish.jpg
July 19, 2023 at 11:09 am #14065581

mariaA-45

Hi,

and thanks for your effort.

Unfortunately, I cannot confirm that it works now. As a matter of fact, the behavior is exactly as originally described above, i.e. I see two memberships, when ordering the Danish product and I see no membership at all, when ordering the English translation of that product.

My guess is that you confused yourself by not cleaning up your orders before testing orders in different languages. Your screenshots even confirms that. If (and only if), the order process works correctly, then the Thank-You page will contain an extra paragraph describing, which membership your account was enrolled in due to your purchase. None of your two screenshots contains that paragraph. Please see the thick-bordered red box in my screenshot for details.

For your further testing, please note these mechanics:
- if you purchase a trigger product, you will be enrolled in the corresponding membership.
- if you already are enrolled in that membership, then you will not be enrolled again and the thank-you page will thus not contain the special "membership paragraph" (see my screenshot, pls).
- it is therefore important that you remove your orders AND your memberships from WooCommerce in between test orders.

For details on how to remove orders and memberships, please refer to my howto sent along with the temp. login link in my previous (private) message.

Thanks again for your help!
Maria

2023-07-19 12_51_26-Checkout – DeveloBaby.png
July 19, 2023 at 1:13 pm #14066413

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Yes, that makes sense.

Thank you for clarifying. I'll do my tests again and proceed accordingly.

I am working on it and 'll update you as soon as I've more information or a solution.

July 20, 2023 at 6:51 am #14069301

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting on this, I understand the problem now and looks like I need to escalate the issue to the relevant team.

May I ask for a copy of your website to test in another environment and for escalation? This way we'll be able to figure out the problem more efficiently and provide a relevant solution. Please see https://wpml.org/faq/provide-supporters-copy-site/ for more details.

I've set your next reply as private to share this information safely.

Or please let me know, I can create a package using Duplicator plugin.

July 20, 2023 at 8:36 am #14070309

mariaA-45

Hi there,

- Cleaned the database from all customer data and removed the biggest media files (lots of videos on my site).
- Re-confirmed that the issue still exists. It does.
- Created a Duplicator package.

Please download the duplicator package directly from the staging sites back end.

Thanks!
Maria

July 20, 2023 at 1:15 pm #14072683

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your cooperation.

I've downloaded the package and 've escalated the matter to the 2nd tier team. I'll update you as soon as I hear back.

July 21, 2023 at 6:18 am #14075985

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Just an update, that, matter is now with our compatibility team. Because plugin is on our compatibility list and there, perhaps, something needs to be taken care of.

I'll update you as soon as I've more information.

July 27, 2023 at 5:31 am #14107709

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience on this.

We've tried the site package on local and then tried to reproduce in another environment but without any luck.

I've prepared this hidden link fresh sandbox site with the same plugins active as in the package. Only WPML is configured.

Can you please activate and configure other plugins? And then create one or two sample products with sample memberships, and, then reproduce the issue in the sandbox?

While you are doing this, please take note of any special steps or settings needed to setup the plugins and/or products and memberships. This 'll help understanding the process.

Please let me know.

July 28, 2023 at 3:09 am #14114461

mariaA-45

Hi there,

I configured all necessary plugins, pages and memberships in your sandbox and was able to reproduce the original issue. I took notes of these steps along the way:

- Plugins: enable WooCommerce

- WooCommerce Setup Wizard:
-- Just getting started
-- Shop Location: Denmark
-- no plugins

- WooCommerce, Settings:
-- General:
--- Selling location(s): Sell to specific countries
--- Sell to specific countries: Denmark
--- Shipping Location(s): Disable Shipping
--- Currency: Danish krone (kr.)
-- Products
--- Inventory:
---- Manage stock: Enable stock Management: Disabled
-- Payments:
--- Cash on Delivery: Enabled
-- Accounts:
--- Allow customers to place orders without an account: Disabled
--- Allow customers to log into an existing account during checkout: Enabled
--- Allow customers to create an account during checkout: Enabled
--- Allow customers to create an account on the "My account" page: Disabled

- Plugins: enabled WooCommerce Multilingual & Multicurrency
-- Store Pages: all default
-- Global Attributes: all default
-- Multiple Currencies: only one
-- Translation Options: Do not allow viewing products in languages they are not translated to

- Products: Create product:
-- Product Name: "Trigger Product"
-- Virtual Product: Enabled
-- Downloadable Product: Enabled
-- Price: 100
-- Inventory: Limit purchases to 1 item per order: Enabled
-- publish
-- then add English Translation "Trigger Product EN"

- Pages: Create page
-- page name "Membership Contents"
-- publish
-- and add English Translation "Membership Contents EN"

- Plugins: enable WooCommerce Memberships

- Plugins: WooCommerce Memberships => Setup
-- Page Settings:
--- Hide Completely
-- Page Access:
--- How do customers become members?: Customers become members when they purchase a particular product
--- Which products can be purchased to become a member? "Trigger Product"
--- How long? ... Does not end.
-- Member Perks: none
-- Member Emails: none

- WooCommerce => Memberships => Membership Plans => "VIP Membership" => Edit
-- Restrict Content: Add New Rule
-- Type: Page
-- Title: "Memberships Contents" (I only add the original page here, but not the translated page!)
-- Publish

- WooCommerce => Memberships => Membership Plans => "VIP Membership" => Add English translation "VIP Membership EN"

- Marketing => Coupons => Add Coupon
-- Name "VIP"
-- Discount Type: Percentage
-- Coupon amount: 100
-- publish

- Visit site in Private Mode (so we're no longer logged on as site-admin):
-- hidden link : looks good
-- Check that the membership pages are NOT accessible:
--- hidden link not accessible => expected, because I am not logged in!
--- hidden link this is accessible => not expected!

- Visit store in Private Mode and purchase product in MAIN language using coupon code "vip" (just to make test checkouts faster)
-- Note: on thank you page, I am explicitely enrolled in "VIP Membership EN" and "VIP Membership". This is not expected. I would expect that only the enrollment in the main language "VIP Membership" is listed here, because that is what I bought access to.

- Now in WordPress back end
-- WooCommerce Orders: delete the order remember to empty the trash!
-- WooCOmmerce Memberships: delete the two memberships

- Visit store in Private Mode and purchase product in ENGLISH language using coupon code "vip" (just to make test checkouts faster)
-- Note: on thank you page, there is no membership mentioned anymore. This is not expected! I would expect that I am enrolled in the English membership "VIP Membership EN".
-- To confirm, check WordPress backend, under WooCommerce Memberships: and yes, there are no memberships despite the purchase of the English Trigger product

Best,
Maria

July 28, 2023 at 7:03 am #14114837

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks a lot Maria, that was awesome and of great help.

I've escalated the issue to our compatibility team and 'll update you as soon as there's some progress or information.

Have a great weekend.

August 2, 2023 at 5:52 am #14138827

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation.

Our team has identified the problems and have escalated the matters to relevant dev and compatibility teams.

For now they offer following workarounds to the identified problems. We've applied these on our sandbox and 've tested.

Please consider followings and apply these first on your staging site:

IMPORTANT: Take full backup before proceeding!!

Issue #1: Restricted content visible in second language

We found that the issue happens because the translation is using the same slug as the default language. Modified the slug and now it works as expected (not visible for all users): i.e. hidden link

Issue #2: Memberships from other languages being displayed on thank-you page

This can be solved with the following workaround:

- Open the "wp-content\plugins\woocommerce-memberships\src\functions\wc-memberships-functions-orders.php" file
- Inside function "wc_memberships_get_order_thank_you_links()" replace the following snippet (around line) 274:

foreach ( $memberships as $membership_id => $data ) {

	if ( 'yes' === $data['already_granted'] ) {

		$user_membership       = wc_memberships_get_user_membership( (int) $membership_id );
		$membership_plan       = $user_membership ? $user_membership->get_plan() : null;
		$members_area_sections = $membership_plan ? $membership_plan->get_members_area_sections() : array();

		if ( ! empty( $members_area_sections ) ) {
			$memberships_with_members_area[ $user_membership->get_plan_id() ] = $user_membership->get_plan()->get_name();
		}
	}
}

With:

foreach ( $memberships as $membership_id => $data ) {					

	if ( 'yes' === $data['already_granted'] ) {

		$user_membership       = wc_memberships_get_user_membership( (int) $membership_id );
		$membership_plan       = $user_membership ? $user_membership->get_plan() : null;
		$members_area_sections = $membership_plan ? $membership_plan->get_members_area_sections() : array();

		// WPML workaround for compsupp-6889 - Issue #2
		if (class_exists('Sitepress')) {
			$wpml_current_lang = apply_filters( 'wpml_current_language', NULL );

			$args = array('element_id' => $membership_plan->id, 'element_type' => 'wc_membership_plan' );
			$membership_id_language_info = apply_filters( 'wpml_element_language_details', null, $args );

			if ( $wpml_current_lang != $membership_id_language_info->language_code) {
				$members_area_sections = array();
			}
		}

		if ( ! empty( $members_area_sections ) ) {
			$memberships_with_members_area[ $user_membership->get_plan_id() ] = $user_membership->get_plan()->get_name();
		}
	}
}

PS: Now, as we have only one membership, it will display a different message. This is expected.

Issue #3: No membership assigned when purchasing product from 2nd language

This can be solved with the following workaround:

- Open the "wp-content\plugins\woocommerce-memberships\src\class-wc-memberships-membership-plan.php" file
- Replace the "WC_Memberships_Membership_Plan::get_product_ids()" method (around line 218):

public function get_product_ids() {

	if ( null === $this->product_ids ) {
		$this->product_ids = get_post_meta( $this->id, $this->product_ids_meta, true );
		$this->product_ids = is_array( $this->product_ids ) ? array_unique( array_map( 'absint', $this->product_ids ) ) : [];
	}

	return $this->product_ids;
}

With:

public function get_product_ids() {

	if ( null === $this->product_ids ) {
		$this->product_ids = get_post_meta( $this->id, $this->product_ids_meta, true );
		$this->product_ids = apply_filters( 'wc_memberships_rule_object_ids', $this->product_ids );
		$this->product_ids = is_array( $this->product_ids ) ? array_unique( array_map( 'absint', $this->product_ids ) ) : [];
	}

	return $this->product_ids;
}

Please try these and let me know.

August 2, 2023 at 9:55 am #14140939

mariaA-45

Hi there,

I did test this in your sandbox and I see a row of problems - did you apply the above work arounds to the sandbox?

I'll describe, what I see step by step:

Step 1:
I removed the existing membership and its translation. Then, I created a new membership plan "VIP Membership Plan Manual" that does not depend on a trigger product, ie. the only way to become member in this plan is to be assigned by an admin. Under "Restrict Content", I only chose the membership page in the first language, but not the translated page. I created this plan to test how memberships are handled by WPML independently of the extra complexity of trigger products.

Observations:
Note, that I have not translated the membership plan yet, but yet reviewing the membership plan configuration, I can see that under "Content Restriction", there are now four pages listed, namely "Membership Contents (60)" (twice) and "Membership Contents EN (62)" (also twice). This is unexpected! Only "Membership Contents (60)" should be listed and only once. I suspect that the translated page is listed, because it is not filtered away (similarly to your above work-arounds), and that all pages are eventually listed twice, because two languages are configured in WPML language settings (but I haven't tested either claim).

Step 2:
Now, I translated the membership plan "VIP Membership Plan Manual" to "VIP Membership Plan Manual EN" and double checked that the slugs are different.

Observations:
Looking at the settings of the translated membership plan in the back end, I can see that there is nothing listed under "Restrict Content". That is not expected. I would like to see "Membership Contents EN (62)" to be listed here.

Step 3:
Under WooCommerce, Memberships, Members, I clicked "Add Member" and added "Maria" as member and enrolled this user to "VIP Membership Plan Manual (#100)".

Observations:
When enrolling "Maria" in a membership plan, I could choose between "VIP Membership Plan Manual (#100)" and "VIP Membership Plan Manual EN (#101)". This is not expected, as I believe the translations of a membership plan should be handled transparently, ie. I would only expect the membership in the first language listed here. Also, after publishing the enrollment, I am only enrolled in the membership plan "VIP Membership Plan Manual EN (#101)", but not in its English translation. I would think that this is unexpected, because enrollment in the membership plan in the first language should trigger automatic enrollment in all translated memberships, too. But let's see, how things look in the front end.

Step 3:
Logged on as "Maria" in private browser, I checked out the membership under my-account:

Observations:
On the front end, under my-account, I can see the membership plan in the first language, and nothing else. Expected! I can also browse the content page at hidden link. Expected. Scrolling to the bottom and choosing English, I get a 404 (ie. I don't have access). This is most definitely not expected, because customers should be able to switch language, once they bought a membership (in any language). It is also not expected, because the membership plan did specifically list all translated membership content pages under "Restrict Content" (see observations under Step 1).

Step 4:
Now, I unenrolled myself from all memberships and enrolled myself in the translated membership "VIP Membership Plan Manual EN (#101)". I want to see, if I get access to the correct pages.

Observations:
On the front-end, under my-account, I can now see the enrollment in the translated membership plan, but the plan has no content, which (kind of) makes sense, because that is what we saw under observations in step 2. Curiously, I do have access to the translated membership page at hidden link, but not to the first language page at hidden link. Again, not expected.

Step 5:
Just to see, what it would look like to be automatically enrolled in all translated memberships, I enrolled myself manually in "VIP Membership Plan Manual (#100)" and also in "VIP Membership Plan Manual EN (#101)".

Observations:
Under hidden link I can now see that I am enrolled in two memberships. I sort of expect this, because I enrolled myself manually in first and second language membership plans, but normally this shoudn't happen. I expect that only the membership plan that I was originally enrolled in, would be listed here and the translated membership plan enrollments are handled invisibly in the background. Yet, I have access to both membership content pages now. This is good.

I might misunderstand the basic concepts of how WPML handles memberships plans. I noticed that memberships as listed at hidden link can have translations, too. So perhaps being enrolled in one membership plan, should result in me becoming member of that plan, but also member of all plan translations, however via automatically translating the membership rather than being enrolled in all translated membership plans? Either way, in its current state WPML does not work for WooCommerce Memberships - not even without trigger products.