<?php
/**
 * Variable product commission Template
 *
 * @since 3.0.0
 * @package wc-affiliate
 *
 * @var int $loop
 * @var object $variation
 */

echo wp_kses_post( "<div class='wf-affiliate_commission'>" );
woocommerce_wp_select(
	array(
		'id'            => 'affiliate_commission[' . $loop . ']',
		'type'          => 'checkbox',
		'class'         => 'affiliate_commission wf-variation-commission-option',
		'wrapper_class' => 'wf-variation-commission-panel',
		'label'         => __( 'Affiliate Commission', 'wc-affiliate' ),
		'value'         => get_post_meta( $variation->ID, 'affiliate_commission', true ),
		'options'       => array(
			'default'  => __( 'Default', 'wc-affiliate' ),
			'disabled' => __( 'Disabled', 'wc-affiliate' ),
			'custom'   => __( 'Custom', 'wc-affiliate' ),
		),
	)
);

$_commission_type = get_post_meta( $variation->ID, 'commission_type', true );
$commission_type  = ! empty( $_commission_type ) ? $_commission_type : wca_get_option( 'basic', 'commission.commission_type' );
woocommerce_wp_select(
	array(
		'id'            => 'commission_type[' . $loop . ']',
		'class'         => 'wf-variation-commission-type',
		'wrapper_class' => 'wf-variation-commission-type-panel',
		'label'         => '',
		'selected'      => true,
		'value'         => $commission_type,
		'options'       => array(
			''        => __( 'Commission Type', 'wc-affiliate' ),
			'fixed'   => __( 'Fixed', 'wc-affiliate' ),
			'percent' => __( 'Percent', 'wc-affiliate' ),
		),
	)
);

$_commission_amount = get_post_meta( $variation->ID, 'commission_amount', true );
$commission_amount  = ! empty( $_commission_amount ) ? $_commission_amount : wca_get_option( 'basic', 'commission.commission_amount' );
woocommerce_wp_text_input(
	array(
		'id'            => 'commission_amount[' . $loop . ']',
		'type'          => 'number',
		'class'         => 'wf-variation-commission-amount',
		'wrapper_class' => 'wf-variation-commission-amount-panel',
		'label'         => '',
		'value'         => $commission_amount,
	)
);
echo wp_kses_post( '</div>' );
