Blog

Recent Articles from Woocoders on Development

How to create JSON data in javascript?

Create JSON data in javascript Creating JSON data in JavaScript is straightforward. JavaScript has a built-in object called JSON that includes methods for converting JavaScript objects to JSON strings and vice versa. Step-by-Step guide to create JSON data in javascript Code Example Here’s a complete example of how to do

How to create JSON data in php?

To create JSON data in PHP, you can use the json_encode() function, which converts a PHP array or object into a JSON string. Here is a step-by-step example: Here’s a complete example: Step-by-Step Example Step 1: Create the PHP Array First, define an array with your data: Step 2: Encode

WordPress REST API – custom routes & endpoints

The WordPress REST API has revolutionized how developers interact with WordPress sites, offering a robust set of endpoints for managing content and performing various operations. While the API comes with a predefined set of routes for core functionalities, developers often need to create custom routes and endpoints to extend WordPress’

How to add custom text field with product for checkout in Woocommerce?

Custom Text field for custom product in woocommerce if ( ! function_exists( ‘yith_wc_custom_input_text’ ) ) { /** * Display input text before add to cart button. */ function yith_wc_custom_input_text() { global $product; $product_id = $product ? $product->get_id() : 0; $products_to_show = array( 2874, 28 ); if ( $product_id && in_array(

Remove checkout fields for a defined product category in Woocommerce

add_filter( ‘woocommerce_checkout_fields’, ‘conditionally_remove_checkout_fields’, 25, 1 ); function conditionally_remove_checkout_fields( $fields ) { // HERE the defined product Categories $categories = array(‘house’); $found = false; // CHECK CART ITEMS: search for items from our defined product category foreach ( WC()->cart->get_cart() as $cart_item ){ if( has_term( $categories, ‘product_cat’, $cart_item[‘product_id’] ) ) { $found

Check if Product ID is Contained in the Cart – WooCommerce

add_action( ‘woocommerce_before_cart’, ‘bbloomer_find_product_in_cart’ ); function bbloomer_find_product_in_cart() { $product_id = 282; $product_cart_id = WC()->cart->generate_cart_id( $product_id ); $in_cart = WC()->cart->find_product_in_cart( $product_cart_id ); if ( $in_cart ) { $notice = ‘Product ID ‘ . $product_id . ‘ is in the Cart!’; wc_print_notice( $notice, ‘notice’ ); } }

Print PDF directly from JavaScript

Print PDF directly from JavaScript function printFile(url) { const iframe = document.createElement(‘iframe’); iframe.src = url; iframe.style.display = ‘none’; document.body.appendChild(iframe); // Use onload to make pdf preview work on firefox iframe.onload = () => { iframe.contentWindow.focus(); iframe.contentWindow.print(); }; }

How to validate email in js?

How to validate email in js? Email validation is a crucial aspect of web development when it comes to ensuring data integrity and user experience. Whether you’re building a registration form, a subscription service, or any application that requires user input, validating email addresses is essential to prevent errors and

How to update minicart after product added into cart?

They move the global enqueue support for fragments refreshso call wp_enqueue_script( ‘wc-cart-fragments’ ); in your theme or Call the WC_AJAX::get_refreshed_fragments() at the end of your PHP coode responder; if it comes from an AJAX call var fragments = response.fragments; if ( fragments ) {jQuery.each(fragments, function(key, value) {jQuery(key).replaceWith(value);});}

WooCommerce shopping mini cart isn’t updated after ajax adding items

They move the global enqueue support for fragments refreshso call wp_enqueue_script( ‘wc-cart-fragments’ ); in your theme or Call the WC_AJAX::get_refreshed_fragments() at the end of your PHP coode responder; if it comes from an AJAX call var fragments = response.fragments; if ( fragments ) {jQuery.each(fragments, function(key, value) {jQuery(key).replaceWith(value);});}

Refresh cart_fragments(mini-cart) by PHP or jQuery

They move the global enqueue support for fragments refreshso call wp_enqueue_script( ‘wc-cart-fragments’ ); in your theme or Call the WC_AJAX::get_refreshed_fragments() at the end of your PHP coode responder; if it comes from an AJAX call var fragments = response.fragments; if ( fragments ) {jQuery.each(fragments, function(key, value) {jQuery(key).replaceWith(value);});}

Fragments to Update Cart Counter not working

They move the global enqueue support for fragments refreshso call wp_enqueue_script( ‘wc-cart-fragments’ ); in your theme or Call the WC_AJAX::get_refreshed_fragments() at the end of your PHP coode responder; if it comes from an AJAX call var fragments = response.fragments; if ( fragments ) {jQuery.each(fragments, function(key, value) {jQuery(key).replaceWith(value);});}

Contact Form 7 AJAX Callback

And the valid events are: wpcf7invalid — Fires when an Ajax form submission has completed successfully, but mail hasn’t been sent because there are fields with invalid input. wpcf7spam — Fires when an Ajax form submission has completed successfully, but mail hasn’t been sent because a possible spam activity has been detected.

Website Designer Sangrur in 2023 | +91 97815-97815

Website Designer Sangrur in 2021: We are best in website designing services in Sangrur. We are keep updating our services to give you a better business this year. Whatever your business is about services or a product, you need a website to introduce your business to your customers. So, you

How to get a site url in WordPress code?

Getting the Site’s URL Let’s say your site’s URL is http://example.com. If you want to print this out in the source, you can use the url parameter. This works great for absolute link references. For example, if you wanted to reference your logo (let’s say the file name is logo.png) that is in a