Created
February 14, 2021 22:37
-
-
Save hamidrezayazdani/f8a71efb0ff468ac25fd4cb9bc74af64 to your computer and use it in GitHub Desktop.
تغییر متن دکمه «افزودن به سبد خرید» برای محصولات دانلودی رایگان
This file contains 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 | |
/** | |
* تغییر متن دکمه «افزودن به سبد خرید» برای محصولات دانلودی رایگان | |
*/ | |
// تغییر متن دکمه در فروشگاه، دسته و برچسب محصول و صفحات آرکایو | |
add_filter( 'woocommerce_product_add_to_cart_text', 'ywp_custom_product_add_to_cart_text', 10, 2 ); | |
// تغییر متن دکمه در صفحه محصول | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'ywp_custom_product_add_to_cart_text', 10, 2 ); | |
function ywp_custom_product_add_to_cart_text( $add_to_cart_text, $product ) { | |
if( $product->is_in_stock() && $product->is_downloadable() && $product->get_price() == 0 ) { // محصول موجود، دانلودی و قیمتش صفر باشه | |
return 'دانلود'; | |
} | |
return $add_to_cart_text; // متن پیشفرض رو برمیگردونیم | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment