| 1 |
<?php |
| 2 |
/** |
| 3 |
* WooCommerce Coupon Restriction Option Template |
| 4 |
* |
| 5 |
* @package Timetics |
| 6 |
*/ |
| 7 |
|
| 8 |
$selected_ids = get_post_meta( $coupon_id, 'timetics_meeting_ids', true ); |
| 9 |
$selected_ids = ! empty( $selected_ids ) ? $selected_ids : []; |
| 10 |
|
| 11 |
?> |
| 12 |
<p class="form-field"> |
| 13 |
<label><?php _e( 'Timetics Meetings', 'timetics' ); ?></label> |
| 14 |
<select class="timetics-product-search" multiple="multiple" style="width: 50%;" name="timetics_meeting_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'timetics' ); ?>"> |
| 15 |
<?php |
| 16 |
$args = array( |
| 17 |
'status' => 'publish', |
| 18 |
'limit' => -1, |
| 19 |
'category' => array( 'timetics-meeting' ), |
| 20 |
); |
| 21 |
$products = wc_get_products( $args ); |
| 22 |
|
| 23 |
foreach ( $products as $product ) { |
| 24 |
$selected = in_array( $product->get_id(), $selected_ids ); |
| 25 |
if ( is_object( $product ) ) { |
| 26 |
echo '<option value="' . esc_attr( $product->get_id() ) . '"' . selected( $selected, true, false ) . '>' . esc_html( wp_strip_all_tags( $product->get_formatted_name() ) ) . '</option>'; |
| 27 |
} |
| 28 |
} |
| 29 |
?> |
| 30 |
</select> |
| 31 |
<?php echo wc_help_tip( __( 'Products that the coupon will be applied to, or that need to be in the cart in order for the "Fixed cart discount" to be applied.', 'timetics' ) ); ?> |
| 32 |
</p> |
| 33 |
<script> |
| 34 |
jQuery(function($) { |
| 35 |
$('.timetics-product-search').select2(); |
| 36 |
}); |
| 37 |
</script> |
| 38 |
|