Skip to content

Instantly share code, notes, and snippets.

@gaupoit
Last active June 18, 2020 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaupoit/1c789329c644f8072af660320a959d97 to your computer and use it in GitHub Desktop.
Save gaupoit/1c789329c644f8072af660320a959d97 to your computer and use it in GitHub Desktop.
woocommerce_product_data_panels usage example
<?php
add_action( 'woocommerce_product_data_panels', 'show_ppwp_access_link_tab_content' );
function show_ppwp_access_link_tab_content() {
global $woocommerce, $post;
?>
<div id="ppwp_woo_options" class="panel woocommerce_options_panel">
<?php
woocommerce_wp_select(
array(
'id' => '_ppwp_woo_protected_post',
'label' => __( 'Protected post', 'woocommerce' ),
'options' => array(
'0' => '-- Select a password protected page --',
),
)
);
woocommerce_wp_text_input(
array(
'id' => '_ppwp_woo_usage_limit',
'label' => __( 'Usage limit', 'woocommerce' ),
'desc_tip' => 'true',
'description' => __( 'Enter the number of times user can access the link.', 'woocommerce' ),
'type' => 'number',
'custom_attributes' => array(
'min' => '1',
'step' => '1',
),
)
);
woocommerce_wp_text_input(
array(
'id' => '_ppwp_woo_expiration',
'label' => __( 'Expiration (minutes)', 'woocommerce' ),
'desc_tip' => 'true',
'description' => __( 'Enter the number of minutes the link is valid for.', 'woocommerce' ),
'type' => 'number',
'custom_attributes' => array(
'min' => '1',
'step' => '1',
),
)
);
woocommerce_wp_textarea_input(
array(
'id' => '_ppwp_woo_custom_text',
'label' => __( 'Custom text', 'woocommerce' ),
'desc_tip' => 'true',
'description' => __( 'Insert any text that you want to include in the order product details. The text within the percent sign % % will become Bypass URL. Use {usage_limit} to display password usage limit and {expiration} to display expiry date.', 'woocommerce' ),
)
);
?>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment