File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -352,6 +352,12 @@ protected static function generate_variable_product() {
352352 'downloadable ' => false ,
353353 'image_id ' => self ::get_image (),
354354 ) );
355+
356+ // Set COGS if the feature is enabled.
357+ if ( wc_get_container ()->get ( 'Automattic\WooCommerce\Internal\CostOfGoodsSold\CostOfGoodsSoldController ' )->feature_is_enabled () ) {
358+ $ variation ->set_props ( array ( 'cogs_value ' => round ( $ price * ( 1 - self ::$ faker ->numberBetween ( 15 , 60 ) / 100 ), 2 ) ) );
359+ }
360+
355361 $ variation ->save ();
356362 }
357363 $ data_store = $ product ->get_data_store ();
@@ -416,6 +422,11 @@ protected static function generate_simple_product() {
416422 'gallery_image_ids ' => $ gallery ,
417423 ) );
418424
425+ // Set COGS if the feature is enabled.
426+ if ( wc_get_container ()->get ( 'Automattic\WooCommerce\Internal\CostOfGoodsSold\CostOfGoodsSoldController ' )->feature_is_enabled () ) {
427+ $ product ->set_props ( array ( 'cogs_value ' => round ( $ price * ( 1 - self ::$ faker ->numberBetween ( 15 , 60 ) / 100 ), 2 ) ) );
428+ }
429+
419430 return $ product ;
420431 }
421432
You can’t perform that action at this time.
0 commit comments