Title: Custom Variable Product Type
Last modified: July 9, 2020

---

# Custom Variable Product Type

 *  [assadnazar](https://wordpress.org/support/users/assadnazar/)
 * (@assadnazar)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/custom-variable-product-type/)
 * Hi support team,
    I registered a custom product type which extends WC_Product_Variable
   class.
 * In the backend, I can create custom product and set its attributes and variations.
 * But on the front-end, I am getting
 * > This product is currently out of stock and unavailable.
 * Here is my class:
 *     ```
       <?php
   
       class KNL_SHOP_WC_GIFTCARD_PROD_TYPE extends WC_Product_Variable {
       	public function __construct( $product = 0 ) {
       		parent::__construct( $product );
       	}
   
       	public function get_type() {
       		return 'knl_shop_giftcard';
       	}
   
       	/*public function is_purchasable() {
       		return apply_filters( 'woocommerce_is_purchasable', true, $this );
       	}*/
   
       	public function knl_shop_giftcard_add_to_cart() {
       		global $product;
   
       		$get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );
   
       		wc_get_template('single-product/add-to-cart/giftcard.php',
       			$args = array(
       					'available_variations' => $get_variations ? $product->get_available_variations() : false,
       					'attributes'           => $product->get_variation_attributes(),
       					'selected_attributes'  => $product->get_default_attributes(),
       			),
       			$template_path = '',
       			KNL_SHOP_PATH . '/woocommerce/'
       		);
       	}
       }
       ```
   
 * For template, I copied and renamed variable.php template.
 * Any help will be appreciated.
    -  This topic was modified 5 years, 11 months ago by [assadnazar](https://wordpress.org/support/users/assadnazar/).
      Reason: template info added

Viewing 1 replies (of 1 total)

 *  Thread Starter [assadnazar](https://wordpress.org/support/users/assadnazar/)
 * (@assadnazar)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/custom-variable-product-type/#post-13102106)
 * Code Details are available [here](https://stackoverflow.com/questions/62814241/woocommerce-custom-variable-product-type-out-of-stock-issue)

Viewing 1 replies (of 1 total)

The topic ‘Custom Variable Product Type’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [assadnazar](https://wordpress.org/support/users/assadnazar/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/custom-variable-product-type/#post-13102106)
 * Status: not resolved