Skip to content

Commit 80a8d58

Browse files
authored
Merge pull request #32 from aplazame/campaign_variableprod
Fix for add variable products to campaigns
2 parents 6bf723a + 6162f4c commit 80a8d58

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

plugin/templates/product/campaigns.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
<?php
22
global $post;
33

4-
$articles = array( Aplazame_Aplazame_Api_BusinessModel_Article::createFromProduct( new WC_Product( $post ) ) );
4+
$articles = array();
5+
$product = wc_get_product( $post );
6+
7+
switch ( WC_Aplazame::_m_or_a( $product, 'get_type', 'product_type' ) ) {
8+
case 'variable':
9+
$children_ids = $product->get_children();
10+
11+
foreach ( $children_ids as $child_id ) {
12+
$child = wc_get_product( $child_id );
13+
$articles[] = Aplazame_Aplazame_Api_BusinessModel_Article::createFromProduct( $child );
14+
}
15+
break;
16+
17+
default:
18+
$articles[] = Aplazame_Aplazame_Api_BusinessModel_Article::createFromProduct( $product );
19+
}
20+
521
?>
622

723
<div id="aplazame_campaigns_tab" class="panel woocommerce_options_panel">

0 commit comments

Comments
 (0)