// Add new stock status options function filter_woocommerce_product_stock_status_options( $status ) { // Add new statuses $status['pre_order'] = __( 'Levertijd: 1 week', 'woocommerce' ); $status['contact_us'] = __( 'Levertijd: 12 tot 14 weken', 'woocommerce' ); return $status; } add_filter( 'woocommerce_product_stock_status_options', 'filter_woocommerce_product_stock_status_options', 10, 1 ); // Availability text function filter_woocommerce_get_availability_text( $availability, $product ) { // Get stock status switch( $product->get_stock_status() ) { case 'pre_order': $availability = __( 'Levertijd: 1 week', 'woocommerce' ); break; case 'contact_us': $availability = __( 'Levertijd: 12 tot 14 weken', 'woocommerce' ); break; } return $availability; } add_filter( 'woocommerce_get_availability_text', 'filter_woocommerce_get_availability_text', 10, 2 ); // Admin stock html function filter_woocommerce_admin_stock_html( $stock_html, $product ) { // Simple if ( $product->is_type( 'simple' ) ) { // Get stock status $product_stock_status = $product->get_stock_status(); // Variable } elseif ( $product->is_type( 'variable' ) ) { foreach( $product->get_visible_children() as $variation_id ) { // Get product $variation = wc_get_product( $variation_id ); // Get stock status $product_stock_status = $variation->get_stock_status(); /* Currently the status of the last variant in the loop will be displayed. So from here you need to add your own logic, depending on what you expect from your custom stock status. By default, for the existing statuses. The status displayed on the admin products list table for variable products is determined as: - Product should be in stock if a child is in stock. - Product should be out of stock if all children are out of stock. - Product should be on backorder if all children are on backorder. - Product should be on backorder if at least one child is on backorder and the rest are out of stock. */ } } // Stock status switch( $product_stock_status ) { case 'pre_order': $stock_html = '<mark class="pre-order" style="background:transparent none;color:#33ccff;font-weight:700;line-height:1;">' . __( 'Levertijd: 1 week', 'woocommerce' ) . '</mark>'; break; case 'contact_us': $stock_html = '<mark class="contact-us" style="background:transparent none;color:#cc33ff;font-weight:700;line-height:1;">' . __( 'Levertijd: 12 tot 14 weken', 'woocommerce' ) . '</mark>'; break; } return $stock_html; } add_filter( 'woocommerce_admin_stock_html', 'filter_woocommerce_admin_stock_html', 10, 2 ); // Availability CSS class function filter_woocommerce_get_availability_class( $class, $product ) { // Get stock status switch( $product->get_stock_status() ) { case 'pre_order': $class = 'pre-order'; break; case 'contact_us': $class = 'contact-us'; break; } return $class; } add_filter( 'woocommerce_get_availability_class', 'filter_woocommerce_get_availability_class', 10, 2 ); add_action( 'woocommerce_after_shop_loop_item_title', 'bbloomer_show_stock_shop', 10 ); function bbloomer_show_stock_shop() { global $product; echo wc_get_stock_html( $product ); }
//CSS .stock.in-stock:before { font-family: FontAwesome; content: "\f058"; font-size: 20px; margin-right: 5px; }
In case of any complain or © copyright or issues please check disclaimer page for faster resolutions.
WP Rocket is the best way to boost your site
WP Rocket Plugin WP Rocket is a WordPress plugin that facilitates faster page loads andread more...
Block malicious web traffic
Sucuri firewall The internet is full of malicious actors. There are low-level annoyances like “scriptread more...
Verify that Google can find your page
Google Search console Google Search Console is a free tool from Google that helps youread more...
Search engine optimization by Yoast
Yoast Plugin Search Engine Optimization (SEO) can be a very technical field. It is alsoread more...
E-commerce webshop
E-commerce is a booming industry worldwide. The advent of the internet and the rapid, sustainedread more...
Why should you use Cloudways?
Cloudways hosting Web hosting is an essential service for any internet-based or internet-interfaced business. Whetherread more...
Every website needs hosting
SiteGround hosting Every website needs hosting. Unless you happen to operate a web hosting agency,read more...
Wat is het verschil tussen UX en UI?
UI-design en UX-design In de wereld van webdesign, maar ook in het ontwikkelen van softwareread more...
Create a multilingual wordpress site
Translatepress plug-in The internet is truly global in nature. An internet user in the Netherlandsread more...
Google analytics is a free service provided by Google
Google Analytics Google analytics is a free service provided by Google that helps webmasters, siteread more...
Het snelste en beste webshopplatform Woocommerce
In case of any complain or © copyright or issues please check disclaimer page forread more...