Created
February 23, 2016 21:11
-
-
Save vimes1984/b1db7e720f3b8f382eda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_product_options_general_product_data', __CLASS__ . '::subscription_pricing_fields' ); | |
function remove_prcing(){ | |
remove_action('woocommerce_product_options_general_product_data','WC_Subscriptions_Admin::subscription_pricing_fields' ); | |
} | |
add_action('init', 'remove_prcing'); | |
add_action('woocommerce_product_options_general_product_data','subscription_pricing_fields' ); | |
/** | |
* Output the subscription specific pricing fields on the "Edit Product" admin page. | |
* | |
* @since 1.0 | |
*/ | |
function subscription_pricing_fields() { | |
global $post; | |
// Set month as the default billing period | |
if ( ! $subscription_period = get_post_meta( $post->ID, '_subscription_period', true ) ) { | |
$subscription_period = 'month'; | |
} | |
echo '<div class="options_group subscription_pricing show_if_subscription">'; | |
echo "TEST"; | |
// Subscription Price | |
woocommerce_wp_text_input( array( | |
'id' => '_subscription_price', | |
'class' => 'wc_input_subscription_price', | |
// translators: %s is a currency symbol / code | |
'label' => sprintf( __( 'Subscription Price (%s)', 'woocommerce-subscriptions' ), get_woocommerce_currency_symbol() ), | |
'placeholder' => _x( 'e.g. 5.90', 'example price', 'woocommerce-subscriptions' ), | |
'type' => 'text', | |
'custom_attributes' => array( | |
'step' => 'any', | |
'min' => '0', | |
), | |
) ); | |
// Subscription Period Interval | |
woocommerce_wp_select( array( | |
'id' => '_subscription_period_interval', | |
'class' => 'wc_input_subscription_period_interval', | |
'label' => __( 'Subscription Periods', 'woocommerce-subscriptions' ), | |
'options' => wcs_get_subscription_period_interval_strings(), | |
) | |
); | |
// Billing Period | |
woocommerce_wp_select( array( | |
'id' => '_subscription_period', | |
'class' => 'wc_input_subscription_period', | |
'label' => __( 'Billing Period', 'woocommerce-subscriptions' ), | |
'value' => $subscription_period, | |
'description' => _x( 'for', 'for in "Every month _for_ 12 months"', 'woocommerce-subscriptions' ), | |
'options' => wcs_get_subscription_period_strings(), | |
) | |
); | |
// Subscription Length | |
woocommerce_wp_select( array( | |
'id' => '_subscription_length', | |
'class' => 'wc_input_subscription_length', | |
'label' => __( 'Subscription Length', 'woocommerce-subscriptions' ), | |
'options' => wcs_get_subscription_ranges( $subscription_period ), | |
) | |
); | |
// Sign-up Fee | |
woocommerce_wp_text_input( array( | |
'id' => '_subscription_sign_up_fee', | |
'class' => 'wc_input_subscription_intial_price', | |
// translators: %s is a currency symbol / code | |
'label' => sprintf( __( 'Sign-up Fee (%s)', 'woocommerce-subscriptions' ), get_woocommerce_currency_symbol() ), | |
'placeholder' => _x( 'e.g. 9.90', 'example price', 'woocommerce-subscriptions' ), | |
'description' => __( 'Optionally include an amount to be charged at the outset of the subscription. The sign-up fee will be charged immediately, even if the product has a free trial or the payment dates are synced.', 'woocommerce-subscriptions' ), | |
'desc_tip' => true, | |
'type' => 'text', | |
'custom_attributes' => array( | |
'step' => 'any', | |
'min' => '0', | |
), | |
) ); | |
// Trial Length | |
woocommerce_wp_text_input( array( | |
'id' => '_subscription_trial_length', | |
'class' => 'wc_input_subscription_trial_length', | |
'label' => __( 'Free Trial', 'woocommerce-subscriptions' ), | |
) ); | |
// Trial Period | |
woocommerce_wp_select( array( | |
'id' => '_subscription_trial_period', | |
'class' => 'wc_input_subscription_trial_period', | |
'label' => __( 'Subscription Trial Period', 'woocommerce-subscriptions' ), | |
'options' => wcs_get_available_time_periods(), | |
'description' => sprintf( __( 'Include an optional period of time to wait before charging the first recurring payment. Any sign up fee will still be charged at the outset of the subscription. %s', 'woocommerce-subscriptions' ), WC_Subscriptions_Admin::get_trial_period_validation_message() ), | |
'desc_tip' => true, | |
'value' => WC_Subscriptions_Product::get_trial_period( $post->ID ), // Explicitly set value in to ensure backward compatibility | |
) ); | |
do_action( 'woocommerce_subscriptions_product_options_pricing' ); | |
wp_nonce_field( 'wcs_subscription_meta', '_wcsnonce' ); | |
echo '</div>'; | |
echo '<div class="show_if_subscription clear"></div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment