Skip to content

Commit c485d7e

Browse files
author
Soare Robert-Daniel
committed
dev: CI
1 parent bb41d96 commit c485d7e

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

tests/e2e/fixtures/create-quantity-matrix-group.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,31 @@
1313
global $args, $wpdb;
1414

1515
$suffix = isset( $args[0] ) ? sanitize_key( $args[0] ) : (string) time();
16+
$product_name = 'PPOM Quantity Matrix Product';
1617

1718
$product_id = (int) $wpdb->get_var(
1819
$wpdb->prepare(
1920
"SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s AND post_title = %s ORDER BY ID DESC LIMIT 1",
2021
'product',
2122
'publish',
22-
'Product 1'
23+
$product_name
2324
)
2425
);
2526

27+
if ( ! $product_id ) {
28+
$product = new WC_Product_Simple();
29+
$product->set_name( $product_name );
30+
$product->set_status( 'publish' );
31+
$product->set_catalog_visibility( 'visible' );
32+
$product->set_regular_price( '9.99' );
33+
$product_id = $product->save();
34+
}
35+
2636
if ( ! $product_id ) {
2737
echo wp_json_encode(
2838
array(
2939
'status' => 'error',
30-
'message' => 'Product 1 not found',
40+
'message' => 'Quantity matrix product could not be created',
3141
)
3242
);
3343
exit( 1 );
@@ -115,7 +125,7 @@
115125
'status' => 'success',
116126
'meta_id' => $meta_id,
117127
'product_id' => $product_id,
118-
'product_name' => get_the_title( $product_id ),
128+
'product_name' => $product_name,
119129
'product_permalink' => get_permalink( $product_id ),
120130
'quantity_field_id' => 'seat_quantity_' . $suffix,
121131
)

0 commit comments

Comments
 (0)