kreativamarketing
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Add new stock statusfunction add_custom_stock_type() { ?> <script type="text/javascript"> jQuery(function(){ jQuery('._stock_status_field').not('.custom-stock-status').remove(); }); </script> <?php woocommerce_wp_select( array( 'id' => '_stock_status', 'wrapper_class' => 'custom-stock-status', 'label' => __( 'Stock status', 'woocommerce' ), 'options' => array( 'instock' => __( '1', 'woocommerce' ), //changed the name 'outofstock' => __( '2', 'woocommerce' ), //changed the name 'onbackorder' => __( '3', 'woocommerce' ), //changed the name 'cuatro' => __( '4', 'woocommerce' ), //added new one ), 'desc_tip' => true, 'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ) ) ); } add_action('woocommerce_product_options_stock_status', 'add_custom_stock_type'); function save_custom_stock_status( $product_id ) { update_post_meta( $product_id, '_stock_status', wc_clean( $_POST['_stock_status'] ) ); } add_action('woocommerce_process_product_meta', 'save_custom_stock_status',99,1); function woo_add_custom_general_fields_save_two( $post_id ){ // Select $woocommerce_select = $_POST['_stock_status']; if( !empty( $woocommerce_select ) ) update_post_meta( $post_id, '_stock_status', esc_attr( $woocommerce_select ) ); else update_post_meta( $post_id, '_stock_status', '' ); } function woocommerce_get_custom_availability( $data, $product ) { switch( $product->stock_status ) { case 'instock': $data = array( 'availability' => __( '1', 'woocommerce' ), 'class' => 'in-stock' ); //changed name break; case 'outofstock': $data = array( 'availability' => __( '2', 'woocommerce' ), 'class' => 'out-of-stock' ); //changed name break; case 'onbackorder': $data = array( 'availability' => __( '3', 'woocommerce' ), 'class' => 'onbackorder' ); //changed name break; case 'cuatro': $data = array( 'availability' => __( '4', 'woocommerce' ), 'class' => 'cuatro' ); //added new one break; } return $data; } add_action('woocommerce_get_availability', 'woocommerce_get_custom_availability', 10, 2);
There you go. Hope it works for you
Forum: Plugins
In reply to: [WooCommerce] Add new stock statusOkay, thank you for the fast reply.
- This reply was modified 4 years, 10 months ago by kreativamarketing.
Forum: Plugins
In reply to: [WooCommerce] Add new stock statusThank you, I didn’t know wether it was possible or not.
So the way to do it would be to add custom code like the one in functions.php, right?Thank you, turns out the file I was modifying wasn’t located in my-theme/dokan/products. I changed the file location to that one and now the changes are applying.
Also, is there a way to change the Product type to only Simple?