Month: May 2020

Click on map and get Longitude -Latitude

<div id=”MyMap” style=”width:100%;height:500px;”></div> <script> function myMap() {   var mapCanvas = document.getElementById(“MyMap”);   var myCenter=new google.maps.LatLng(51.508742,-0.120850);   var mapOptions = {center: myCenter, zoom: 5};   var map = new google.maps.Map(mapCanvas, mapOptions);   google.maps.event.addListener(map, ‘click’, function(event) {     LocationMarker(map, event.latLng);   }); } function LocationMarker(map, location) {   var marker = new google.maps.Marker({     position: location,     map: map   });   var infowindow = new google.maps.InfoWindow({     content: …

Click on map and get Longitude -Latitude Read More »

WooCommerce: Show Required Field Errors Inline on Checkout Page

For Showing inline required error , first we search all fields that are required and have labels , and before the closing label tag we add a span containing error. By default, this is set as display:none, which will be displayed via CSS later. Before: function CheckoutFieldsInlineError( $field, $key, $args, $value ) {   if ( …

WooCommerce: Show Required Field Errors Inline on Checkout Page Read More »

WooCommerce : Add Custom Taxonomy Filter on Products Dashboard

When we go to WordPress Dashboard > Products. We see Many Product filters such as “Select a category”, “Filter by product type”, “Filter by stock status”. For Adding More filters as our requirements. like Product tags. function CustomTaxonomyFilter( $data ) {   global $wp_query;   $data .= wc_product_dropdown_categories( array(     ‘show_option_none’ => ‘Filter by Tags’,     ‘taxonomy’ => ‘product_tag’, …

WooCommerce : Add Custom Taxonomy Filter on Products Dashboard Read More »

WooCommerce : Remove Metaboxes On Product Edit Admin Page

For Disabling Product tags or Product short description on product edit page we need the “ID” of the metabox and its position (‘normal’ or ‘side’). For example: function RemoveProductMetaboxes() {   // For remove short description   remove_meta_box( ‘postexcerpt’, ‘product’, ‘normal’ );   // For remove product tags   remove_meta_box( ‘tagsdiv-product_tag’, ‘product’, ‘side’ ); } add_action( ‘add_meta_boxes_product’, ‘RemoveProductMetaboxes’, 99 …

WooCommerce : Remove Metaboxes On Product Edit Admin Page Read More »

WooCommerce : Add New Page and Link it to WordPress > Products

For Adding A Submenu on product menu you can use default ‘admin_menu’ hook. For example: function ProductsSubPage() {   add_submenu_page( ‘edit.php?post_type=product’, ‘Custom Page Title’, ‘New Custom Title’, ‘edit_products’, ‘new_page_slug’, ‘ProductsSubPageCallback’, 99 ); } function ProductsSubPageCallback() {   echo ‘<div class=”wrap”><h1 class=””>New Custom Title</h1>’;   // add Content here   echo ‘</div>’; } add_action( ‘admin_menu’, ‘ProductsSubPage’, 99 ); //output Enjoy

WooCommerce : Add text to the WooCommerce thank you page

Sometimes clients need to show some attractive poster or text or may be promotions of other products to show customer on order thank you page ,So the buyers go back to the website and buy again. For This we use simple ‘woocommerce_thankyou’ hook. function AddContentThankyou() {   echo ‘<h2>Get 50% off</h2><p>Thank you for making this purchase! …

WooCommerce : Add text to the WooCommerce thank you page Read More »

WooCommerce : Change “Add to Cart” Text if Product Already in Cart

When a product is in cart , woocomerce still show ‘add to cart’ text. There is no information on shop page or product page that ‘s this product is already in cart. ‘Add To Cart’ text comes from two filter one for shop page, and one for product single page. For Loop Page /shop page …

WooCommerce : Change “Add to Cart” Text if Product Already in Cart Read More »

WooCommerce : Add +(Plus) & -(Minus) Buttons To Quantity Input

Quantity Field is input type number but it’s look not good. instead of it we can use a plus minus button on left and right side of Quantity field. For adding plus and minus button html use ‘woocommerce_before_add_to_cart_quantity’ and ‘woocommerce_after_add_to_cart_quantity’. //For Plus function PlusYourQuantity() {   echo ‘<div class=”minusplusbutton”><button type=”button” class=”add”>+</button>’; } add_action( ‘woocommerce_before_add_to_cart_quantity’, ‘PlusYourQuantity’ ); …

WooCommerce : Add +(Plus) & -(Minus) Buttons To Quantity Input Read More »

WooCommerce : Add New Tab In My Account Page

Adding a Tab in WooCommerce my account page it not to difficult. let’s distribute in 4 steps. Register new endpoint. Add query var. Insert endpoint into the My Account menu. Add content to the newly added endpoint. Step 1 :Register new endpoint. We have to use ‘add_rewrite_endpoint’ Function. function AddCustomTabEndpoint() {   add_rewrite_endpoint( ‘my-custom-tab’, EP_ROOT | …

WooCommerce : Add New Tab In My Account Page Read More »

Scroll to Top