Fix return subscription plan id

This commit is contained in:
Emili Castells Guasch 2023-03-02 09:11:17 +01:00
parent 62364d1e84
commit bdc69a6fc6
3 changed files with 16 additions and 1 deletions

View file

@ -7,6 +7,9 @@ AUTHORIZATION="Bearer ABC123"
WP_MERCHANT_USER="admin"
WP_MERCHANT_PASSWORD="admin"
WP_CUSTOMER_USER="customer"
WP_CUSTOMER_PASSWORD="password"
CUSTOMER_EMAIL="customer@example.com"
CUSTOMER_PASSWORD="password"

View file

@ -1361,7 +1361,7 @@ class SmartButton implements SmartButtonInterface {
assert( $product instanceof WC_Product );
if ( $product->get_type() === 'subscription' && $product->meta_exists( 'ppcp_subscription_plan' ) ) {
return $product->get_meta( 'ppcp_subscription_plan' );
return $product->get_meta( 'ppcp_subscription_plan' )->id;
}
}

View file

@ -2,6 +2,8 @@ const {test, expect} = require('@playwright/test');
const {
WP_MERCHANT_USER,
WP_MERCHANT_PASSWORD,
WP_CUSTOMER_USER,
WP_CUSTOMER_PASSWORD,
AUTHORIZATION
} = process.env;
@ -15,6 +17,16 @@ async function loginAsAdmin(page) {
]);
}
async function loginAsCustomer(page) {
await page.goto('/wp-admin');
await page.locator('input[name="log"]').fill(WP_CUSTOMER_USER);
await page.locator('input[name="pwd"]').fill(WP_CUSTOMER_PASSWORD);
await Promise.all([
page.waitForNavigation(),
page.locator('text=Log In').click()
]);
}
test.describe.serial('Merchant', () => {
const title = (Math.random() + 1).toString(36).substring(7);
let product_id = '';