mehditalaei
تازه وارد
سلام
شورت کدی هست که باهاش بشه تعداد خرید های کاربر رو نمایش داد؟
شورت کدی هست که باهاش بشه تعداد خرید های کاربر رو نمایش داد؟
<?php
//by-yazdanian
$current_user = wp_get_current_user();
$tedadesefaresh = wc_get_customer_order_count( $current_user->ID );
$args = array(
'customer_id' => $current_user->ID,
'post_status' => 'cancelled',
'post_type' => 'shop_order',
'return' => 'ids',
);
$tedadcancellshode = 0;
$tedadcancellshode = count( wc_get_orders( $args ) );
$num_not_cancelled = $tedadesefaresh - $tedadcancellshode;
echo 'تعداد سفارش شا : ';
echo $tedadesefaresh;
echo 'می باشد ';
?>
شورت کد لازم نداره؟سلام وقت بخیر
این کد را جایی ک میخواید نمایش بدید:
PHP:<?php //by-yazdanian $current_user = wp_get_current_user(); $tedadesefaresh = wc_get_customer_order_count( $current_user->ID ); $args = array( 'customer_id' => $current_user->ID, 'post_status' => 'cancelled', 'post_type' => 'shop_order', 'return' => 'ids', ); $tedadcancellshode = 0; $tedadcancellshode = count( wc_get_orders( $args ) ); $num_not_cancelled = $tedadesefaresh - $tedadcancellshode; echo 'تعداد سفارش شا : '; echo $tedadesefaresh; echo 'می باشد '; ?>
نه دیگه این مستقیم توی کدها میاد. ولی خب میتونید ازش شرتکد هم بسازید.شورت کد لازم نداره؟
شرمندهمیشه راهنمایی کنید چجوری شرت کد بسازمنه دیگه این مستقیم توی کدها میاد. ولی خب میتونید ازش شرتکد هم بسازید.
<?php
/**
* @snippet نمایش تعداد محصول خریداری شده توسط کاربر - WooCommerce
* @author payam_yazdainain
* @compatible Woo 3.5.1 up ...
* @شرت کد برای نماش : wooitem
*/
//by-yazdanian
add_shortcode('wooitem', 'payam_yazdainain_kurd_function');
function payam_yazdainain_kurd_function() {
$current_user = wp_get_current_user();
$tedadesefaresh = wc_get_customer_order_count( $current_user->ID );
$args = array(
'customer_id' => $current_user->ID,
'post_status' => 'cancelled',
'post_type' => 'shop_order',
'return' => 'ids',
);
$tedadcancellshode = 0;
$tedadcancellshode = count( wc_get_orders( $args ) );
$num_not_cancelled = $tedadesefaresh - $tedadcancellshode;
echo 'تعداد سفارش شا : ';
echo $tedadesefaresh;
echo 'می باشد ';
}
?>
<?php echo do_shortcode("[wooitem]"); ?>
آقا دمت گرم درست شداگه میخواید این مقادیر رو با شرتکد نشون بدید : کد زیر رو به فانکشن قالب خود اضافه کنید.
سپس با استفاده از شرتکد : [wooitem] نشون بدید.
PHP:<?php /** * @snippet نمایش تعداد محصول خریداری شده توسط کاربر - WooCommerce * @author payam_yazdainain * @compatible Woo 3.5.1 up ... * @شرت کد برای نماش : wooitem */ //by-yazdanian add_shortcode('wooitem', 'payam_yazdainain_kurd_function'); function payam_yazdainain_kurd_function() { $current_user = wp_get_current_user(); $tedadesefaresh = wc_get_customer_order_count( $current_user->ID ); $args = array( 'customer_id' => $current_user->ID, 'post_status' => 'cancelled', 'post_type' => 'shop_order', 'return' => 'ids', ); $tedadcancellshode = 0; $tedadcancellshode = count( wc_get_orders( $args ) ); $num_not_cancelled = $tedadesefaresh - $tedadcancellshode; echo 'تعداد سفارش شا : '; echo $tedadesefaresh; echo 'می باشد '; } ?>
یا
اگه میخواید شرت کدرو تو قالب استفاده کنید از کد زیر استفاده کنید :
PHP:<?php echo do_shortcode("[wooitem]"); ?>