Advertisement
Guest User

WooCommerce Simple Custom product type w/ pre order suppor

a guest
Feb 15th, 2017
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1.  
  2. /* STEP 1 */
  3. function register_simple_custom_product_type() {
  4.  
  5.     class WC_Product_Simple_Custom_Product extends WC_Product_Simple {
  6.  
  7.         public function __construct( $product ) {
  8.  
  9.             $this->product_type = 'simple_custom';
  10.  
  11.             parent::__construct( $product );
  12.         }
  13.     }
  14. }
  15. add_action( 'init', 'register_simple_custom_product_type' );  
  16.  
  17.  
  18.  
  19. /* STEP 2 */
  20. function add_simple_custom_product( $types ){
  21.  
  22.     $types[ 'simple_custom' ] = __( 'Simple custom' );
  23.  
  24.     return $types;
  25. }
  26. add_filter( 'product_type_selector', 'add_simple_custom_product' );  
  27.  
  28.  
  29.  
  30. /* STEP 3*/
  31. function custom_product_tabs( $tabs) {
  32.  
  33.     $tabs['custom'] = array(
  34.         'label'     => __( 'Custom', 'woocommerce' ),
  35.         'target'    => 'custom_options',
  36.         'class'     => array( 'show_if_simple_custom', 'show_if_variable_custom' ),  
  37.     );
  38.  
  39.     return $tabs;
  40. }
  41. add_filter( 'woocommerce_product_data_tabs', 'custom_product_tabs' );  
  42.  
  43.  
  44. function custom_product_data_panels(){
  45.     global $post; ?>
  46.  
  47.     <div id="custom_options" class="panel woocommerce_options_panel wc-metaboxes-wrapper">
  48.             <div class="options_group custom_simple">
  49.  
  50.                 Hello
  51.  
  52.             </div> <!-- options group -->
  53.         </div>
  54. <?php
  55.  
  56. }
  57. add_action( 'woocommerce_product_data_panels', 'custom_product_data_panels' );
  58.  
  59.  
  60. function so_42253729_add_pre_order_support( $types ){
  61.     $types[] = 'simple_custom';
  62.     return $types;
  63. }
  64. add_filter( 'wc_pre_orders_supported_product_types', 'so_42253729_add_pre_order_support' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement