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 | |
/** | |
* add shortcode to wp | |
*/ | |
add_shortcode( 'stock_status', 'display_product_stock_status' ); | |
function display_product_stock_status( $atts) { | |
$atts = shortcode_atts( | |
array('id' => get_the_ID() ), | |
$atts, |
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
<? | |
/** | |
* Add a custom field to woocommerce registeration form | |
*/ | |
add_action( 'woocommerce_register_form', 'ywp_add_name_field_ro_wc_register_form' ); | |
function ywp_add_name_field_ro_wc_register_form() { | |
woocommerce_form_field( | |
'ywp_register_fname', | |
array( | |
'type' => 'text', |
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 | |
$taxonomies = array( | |
'category', // for posts categories | |
'post_tag', // for posts tags | |
'product_tag', // for wc products tags | |
'product_cat', // for wc products categories | |
'product_brand', // for woocommerce brand plugin | |
'brand', // for yith product brand |
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 | |
/** | |
* Convert numbers to english | |
* | |
* @param $input | |
* | |
* @return array|string | |
*/ | |
function ywp_convert_numbers_to_latin( $input ): array|string { | |
$arabic = [ '٩', '٨', '٧', '٦', '٥', '٤', '٣', '٢', '١', '٠' ]; |
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 | |
/** | |
* Add custom endpoint to the My Account menu | |
* | |
* @param array $items | |
* | |
* @return array | |
*/ | |
function ywp_account_menu_custom_item( $items ) { | |
$logout = $items['customer-logout']; |
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
-- توجه: حتما قبل از اجرای این کد، از دیتابیس نسخۀ پشتیبان تهیه کنید -- | |
-- وارد فضای هاست خود شده و PHPMyAdmin را باز کرده و کد زیر را در بخش SQL اجرا کنید. -- | |
-- تبدیل قیمت همه محصولات به تومان -- | |
UPDATE | |
wp_postmeta | |
SET |
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 | |
/** | |
* Add packaging option to order bulk actions | |
*/ | |
function ywp_add_packaging_to_bulk_actions( $actions ) { | |
$actions['mark_packaging'] = 'تغییر وضعیت به بستهبندی'; | |
return $actions; | |
} |
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 | |
$order = wc_get_order( $order_id ); | |
$order_shipping_methods = $order->get_items( 'shipping' ); | |
foreach ( order_shipping_methods as $item_id => $item ) { | |
$shipping_method_instance_id = $item->get_instance_id(); | |
$shipping_method_id = $item->get_method_id(); | |
$shipping_method_title = $item->get_method_title(); | |
$order_item_name = $item->get_name(); |
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 | |
function ywp_date_modified_wc_product_shortcode( $args, $atts ){ | |
$atts = shortcode_atts( | |
array( | |
'orderby' => 'date', | |
'interval' => '20', | |
), $atts, 'bartag' | |
); | |
if ( 'date_modified' === esc_attr( $atts['orderby'] ) ) { |