Untitled
unknown
plain_text
2 years ago
2.7 kB
7
Indexable
add_action( 'marketking_edit_product_after_tags', function($post){ ?> <div class="col-xxl-12 col-md-12 marketking_card_gal_cat_tags" style="background: white; padding:20px;border-radius: 4px;"> <?php $product_id = $post->ID; echo '<h6 class="overline-title title">Max Credit Period</h6><br>'; $groups = get_posts( array( 'post_type' => 'b2bking_group','post_status'=>'publish','numberposts' => -1) ); foreach ($groups as $group){ $set_value = get_post_meta($product_id, 'credit_period_'.$group->ID, true); echo '<label style="width:100px" for="credit_period_'.$group->ID.'">'.esc_html($group->post_title).'</label>'; echo '<select name="credit_period_'.$group->ID.'">'; echo '<option value="1" '.selected($set_value, 1, false).'>1 Day</option>'; echo '<option value="3" '.selected($set_value, 3, false).'>3 Days</option>'; echo '<option value="5" '.selected($set_value, 5, false).'>5 Days</option>'; echo '</select><br><br>'; } echo '<br><h6 class="overline-title title">Accepted Credit Category</h6><br>'; foreach ($groups as $group){ $set_value = get_post_meta($product_id, 'credit_category_'.$group->ID, true); echo '<label style="width:100px" for="credit_category_'.$group->ID.'">'.esc_html($group->post_title).'</label>'; echo '<select name="credit_category_'.$group->ID.'">'; echo '<option value="gold" '.selected($set_value, 'gold', false).'>Gold</option>'; echo '<option value="green" '.selected($set_value, 'green', false).'>Green</option>'; echo '<option value="yellow" '.selected($set_value, 'yellow', false).'>Yellow</option>'; echo '</select><br><br>'; } ?> </div> <?php }); add_action('marketking_after_save_product', function($product_id, $vendor_id){ $groups = get_posts( array( 'post_type' => 'b2bking_group','post_status'=>'publish','numberposts' => -1) ); // save credit period foreach ($groups as $group){ if (isset($_POST['credit_period_'.$group->ID])){ $period = sanitize_text_field($_POST['credit_period_'.$group->ID]); update_post_meta($product_id, 'credit_period_'.$group->ID, $period); } } // save credit category foreach ($groups as $group){ if (isset($_POST['credit_category_'.$group->ID])){ $period = sanitize_text_field($_POST['credit_category_'.$group->ID]); update_post_meta($product_id, 'credit_category_'.$group->ID, $period); } } }, 10, 2);
Editor is loading...