Fragments to Update Cart Counter not working on homepage – Woocommerce

add_filter( ‘woocommerce_add_to_cart_fragments’, function($fragments) { ob_start(); ?> <li class=”my_cart”><a href=”javascript:void(0)” id=”sidebarCollapse” class=”carticonmain”><svg xmlns=”http://www.w3.org/2000/svg” style=”display: none;”> <symbol id=”shopping-cart” viewBox=”0 0 700 700″><title>shopping-cart</title> <path d=”m150.355469 322.332031c-30.046875 0-54.402344 24.355469-54.402344 54.402344 0 30.042969 24.355469 54.398437 54.402344 54.398437 30.042969 0 54.398437-24.355468 54.398437-54.398437-.03125-30.03125-24.367187-54.371094-54.398437-54.402344zm0 88.800781c-19 0-34.402344-15.402343-34.402344-34.398437 0-19 15.402344-34.402344 34.402344-34.402344 18.996093 0 34.398437 15.402344 34.398437 34.402344 0 18.996094-15.402344 34.398437-34.398437 34.398437zm0 0″></path> <path d=”m446.855469 94.035156h-353.101563l-7.199218-40.300781c-4.4375-24.808594-23.882813-44.214844-48.699219-48.601563l-26.101563-4.597656c-5.441406-.96875-10.632812 … Read more

Custom account page that accepts a query parameter

That add_rewrite_endpoint(“scheduled-order-create/([0-9]+)/?”, …); doesn’t work because add_rewrite_endpoint() doesn’t work with custom RegEx pattern. And remember that in addition to default public query vars like cat, tag, year and author, WordPress also makes all public post types and taxonomies (with a non-empty query_var value when registered — see register_post_type() and register_taxonomy()) be readable from the URL … Read more

Unable to call woocommerce hook in my custom php file

You are doing it all wrong, place your code like the following in your file. <?php echo ‘hook called’; // This is not showing any message exit(); global $woocommerce; $product_id = $_POST[‘selected_package_id’]; echo $product_id; // This is not displaying id exit(); $found = false; //check if product already in cart if ( sizeof( WC()->cart->get_cart() ) … Read more

Send Email to Custom Field in Custom Post Type when order is Completed

How to debug Step 1 add_filter( ‘woocommerce_email_headers’, ‘enyc_order_completed_email_add_cc_bcc’, 10, 3 ); function enyc_order_completed_email_add_cc_bcc( $headers, $email_id, $order ) { // CHANGE EMAIL $partnerEmail=”[email protected]”; $headers .= ‘Cc: Name <‘.$partnerEmail.’>’ . ‘\r\n’; // del if not needed $headers .= ‘Bcc: Name <[email protected]>’ . ‘\r\n’; // del if not needed return $headers; } Step 1 works? -> step 2 … Read more