//hide admin notice add_action('admin_enqueue_scripts', 'hidenotice_admin_theme_style'); add_action('login_enqueue_scripts', 'hidenotice_admin_theme_style'); function hidenotice_admin_theme_style() { echo '<style>.update-nag, .updated, .error, .is-dismissible { display: none !important; }</style>'; } //Snippet JavaScript Tulisan Berkedip function ti_custom_javascript() { ?> <script type="text/javascript"> function JavaBlink() { var blinks = document.getElementsByTagName('JavaBlink'); for (var i = blinks.length - 1; i >= 0; i--) { var s = blinks[i]; s.style.visibility = (s.style.visibility === 'visible') ? 'hidden' : 'visible'; } window.setTimeout(JavaBlink, 70); } if (document.addEventListener) document.addEventListener("DOMContentLoaded", JavaBlink, false); else if (window.addEventListener) window.addEventListener("load", JavaBlink, false); else if (window.attachEvent) window.attachEvent("onload", JavaBlink); else window.onload = JavaBlink; </script> <?php } add_action('wp_head', 'ti_custom_javascript'); /* [URLParam param='paramname'] * - shows the value of GET named paramname, or <blank value> if none */ function FeelDUP_Display( $atts ) { extract( shortcode_atts( array( 'param' => 'param', ), $atts ) ); return esc_attr(esc_html($_GET[$param])); } add_shortcode('UBY', 'FeelDUP_Display'); //Max 1 product to add to cart add_filter( 'woocommerce_add_to_cart_validation', 'bbloomer_only_one_in_cart', 99, 2 ); function bbloomer_only_one_in_cart( $passed, $added_product_id ) { wc_empty_cart(); return $passed; } //Rediret if Empty Cart function cart_empty_redirect_to_shop() { global $woocommerce, $woocommerce_errors; if ( is_cart() && sizeof($woocommerce->cart->cart_contents) == 0) { wp_safe_redirect( get_permalink( wc_get_page_id( 'shop' ) ) ); exit; } } add_action( 'template_redirect', 'cart_empty_redirect_to_shop' ); // jQuery - Update checkout on methode payment change add_action( 'wp_footer', 'custom_checkout_jqscript' ); function custom_checkout_jqscript() { if ( is_checkout() && ! is_wc_endpoint_url() ) : ?> <script type="text/javascript"> jQuery( function($){ $('form.checkout').on('change', 'input[name="payment_method"]', function(){ $(document.body).trigger('update_checkout'); }); }); </script> <?php endif; } //Add to cart redirect add_filter( 'woocommerce_add_to_cart_redirect', 'add_to_cart_checkout_redirection', 10, 1 ); function add_to_cart_checkout_redirection( $url ) { return wc_get_checkout_url(); } //* Enqueue scripts and styles add_action( 'wp_enqueue_scripts', 'crunchify_disable_woocommerce_loading_css_js' ); function crunchify_disable_woocommerce_loading_css_js() { // Check if WooCommerce plugin is active if( function_exists( 'is_woocommerce' ) ){ // Check if it's any of WooCommerce page if(! is_woocommerce() && ! is_cart() && ! is_checkout() ) { ## Dequeue WooCommerce styles wp_dequeue_style('woocommerce-layout'); wp_dequeue_style('woocommerce-general'); wp_dequeue_style('woocommerce-smallscreen'); ## Dequeue WooCommerce scripts wp_dequeue_script('wc-cart-fragments'); wp_dequeue_script('woocommerce'); wp_dequeue_script('wc-add-to-cart'); wp_deregister_script( 'js-cookie' ); wp_dequeue_script( 'js-cookie' ); } } } /** * @snippet Remove Order Notes - WooCommerce Checkout * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WooCommerce 5 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_filter( 'woocommerce_enable_order_notes_field', '__return_false', 9999 ); /** * @snippet WooCommerce: Display Product Discount in Order Summary @ Checkout, Cart * @author Sandesh Jangam * @donate $7 https://www.paypal.me/SandeshJangam/7 */ add_filter( 'woocommerce_cart_item_subtotal', 'ts_show_product_discount_order_summary', 10, 3 ); function ts_show_product_discount_order_summary( $total, $cart_item, $cart_item_key ) { //Get product object $_product = $cart_item['data']; //Check if sale price is not empty if( '' !== $_product->get_sale_price() ) { //Get regular price of all quantities $regular_price = $_product->get_regular_price() * $cart_item['quantity']; //Prepend the crossed out regular price to actual price $total = '<span style="text-decoration: line-through; opacity: 0.5; padding-right: 5px;">' . wc_price( $regular_price ) . '</span>' . $total; } // Return the html return $total; } add_action('woocommerce_checkout_before_order_review', 'product_sold_count'); function product_sold_count () { foreach ( WC()->cart->get_cart() as $cart_item ) { $product = $cart_item['data']; $units_sold = $product->get_total_sales(); $stock = $product->get_stock_quantity(); if(!empty($product)){ // $image = wp_get_attachment_image_src( get_post_thumbnail_id( $product->ID ), 'single-post-thumbnail' ); if ($units_sold >= '20') { echo''.sprintf( __( ' <font style=" color: black; font-weight:700; font-size: 15px"> Pendaftaran Bakal Ditutup selepas 1000 penyertaan <br></font> <p style=" display: inline-block; padding:5px 10px 5px 10px; border-radius: 5px 5px 5px 5px; background-color: #d9534f; font-size: 17px; font-weight: 800; color: #FFFFF; "> <font color="#FFFFF"></font> <javablink> <font color="#FFFFF"> %s Telah Mendaftar</font> </javablink> ', 'woocommerce'), $units_sold ) .'</p>';} // to display only the first product image uncomment the line below // break; } } } //Edit Woocommerce Field add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); function custom_override_checkout_fields( $fields ) { unset($fields['billing']['billing_country']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['order']['order_comments']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_company']); unset($fields['billing']['billing_state']); unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_last_name']); $fields['billing']['billing_first_name']['placeholder'] = 'Nama Penuh Anda'; $fields['billing']['billing_first_name']['label'] = 'Masukkan Nama Penuh'; $fields['billing']['billing_first_name']['class'] = 'form-row-wide'; return $fields; } /** * AUTO COMPLETE PAID ORDERS IN WOOCOMMERCE */ add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_paid_order', 10, 1 ); function custom_woocommerce_auto_complete_paid_order( $order_id ) { if ( ! $order_id ) return; $order = wc_get_order( $order_id ); // No updated status for orders delivered with Bank wire, Cash on delivery and Cheque payment methods. if ( ( 'bacs' == get_post_meta($order_id, '_payment_method', true) ) || ( 'cod' == get_post_meta($order_id, '_payment_method', true) ) || ( 'cheque' == get_post_meta($order_id, '_payment_method', true) ) ) { return; } // For paid Orders with all others payment methods (with paid status "processing") elseif( $order->get_status() === 'processing' ) { $order->update_status( 'completed' ); } } /** * @snippet Change "Place Order" Button text @ WooCommerce Checkout * @sourcecode https://rudrastyh.com/woocommerce/place-order-button-text.html#woocommerce_order_button_text * @author Misha Rudrastyh */ add_filter( 'woocommerce_order_button_html', 'misha_custom_button_html' ); function misha_custom_button_html( $button_html ) { $order_button_text = 'Klik Disini Untuk Bayar'; $button_html = ''; echo''.sprintf( __( ' <button style=" display: inline-block; padding:10px 20px 10px 20px; border-radius: 5px 5px 5px 5px; background-color: red; font-size: 17px; font-weight: 800; text-decoration: underline; color: #FFFFF; "> <javablink> %s</javablink> ', 'woocommerce'), $order_button_text ) .'</button>'; return $button_html; } //Buang checkout // hide coupon field on the checkout page function njengah_coupon_field_on_checkout( $enabled ) { if ( is_checkout() ) { $enabled = false; } return $enabled; } add_filter( 'woocommerce_coupons_enabled', 'njengah_coupon_field_on_checkout' ); //sort page date desc function set_post_order_in_admin( $wp_query ) { global $pagenow; if ( is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby'])) { $wp_query->set( 'orderby', 'date' ); $wp_query->set( 'order', 'DESC' ); } } add_filter('pre_get_posts', 'set_post_order_in_admin', 5 );
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter