Created
October 30, 2021 23:50
-
-
Save hamidrezayazdani/f8fb1ac3ba6e9ae5bea869cbf0056252 to your computer and use it in GitHub Desktop.
تعیین حداقل تعداد دو عدد از محصول در هنگام خرید
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change the minimum quantity to 2 | |
*/ | |
function ywp_wc_quantity_input_min_callback( $min, $product ) { | |
return 2; | |
} | |
add_filter( 'woocommerce_quantity_input_min', 'ywp_wc_quantity_input_min_callback', 10, 2 ); | |
/** | |
* Show message to user for minimum quantity | |
*/ | |
function ywp_minimum_qty_msg() { | |
echo '<p style="color:red">حداقل تعداد سفارش 2 عدد است.</p>'; | |
} | |
add_action( 'woocommerce_before_add_to_cart_form', 'ywp_minimum_qty_msg' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment