How to add Buy Now button on Product page – WordPress/woocommerce?

Change && to && add_filter('woocommerce_add_to_cart_redirect', 'malpani_redirect_checkout_add_cart'); function malpani_redirect_checkout_add_cart() { if (isset($_POST["buynow"]) && $_POST["buynow"] === "2") { return wc_get_checkout_url(); } } add_filter('woocommerce_after_add_to_cart_button', 'malpani_add_buy_button'); function malpani_add_buy_button() { echo '<input id="buynowinput" name="buynow" value="1" hidden> <button type="button" id="buy_now" class="buy_now button">Buy Now</button> <script> jQuery(document).ready(function ($) { $("#buy_now").click(function (e) { $("#buynowinput").val(2); $(".single_add_to_cart_button").click(); e.stopPropagation(); e.preventDefault(); }) }); </script>';

October 7, 2020 · 1 min · Harshvardhan Malpani

How to filter and validate pincode in Indian woocommerce?

By default, Woocommerce only validates ZIP code of few countries only. Woocommerce stores in India, are thus invalidated in case of PINCODE inputs from customers. Here is how you can enable checking of pincode for India woocommerce: Put the following code in your custom function file or child theme functions.php add_filter('woocommerce_validate_postcode','validate_indian_postcode',10,3); function validate_indian_postcode($valid, $postcode, $country){ if($country=="IN") $valid = (bool) preg_match( '/^([0-9]{6})$/', $postcode ); // checks your $postcode, if valid $valid will be true because of preg_match else false return $valid; } Reference: https://github.com/woocommerce/woocommerce/blob/ef0f527b40dba539e982efff26211fa577a24cf9/includes/class-wc-validation.php#L44

July 16, 2019 · 1 min · Harshvardhan Malpani

Testing Configuration for Paytm Gateway Plugin India

Paytm Payment Gateway Testing Data Online payment solutions for all your transactions by Paytm Woocommerce Plugin Download the plugin here: https://github.com/Paytm-Payments/Paytm_Woocommerce_Kit Enable/Disable Enable/Disable Enable Paytm Payments. Title Title Paytm This controls the title which the user sees during checkout. Description Description The best payment gateway provider in India for e-payment through credit card, debit card & netbanking. This controls the description which the user sees during checkout. Merchant Identifier Merchant Identifier Merchant Id Provided by Paytm ...

February 7, 2019 · 2 min · Harshvardhan Malpani