Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function display_woocommerce_order_count2( $atts, $content = null ) {
- $args = shortcode_atts( array(
- 'status' => 'completed',
- ), $atts );
- $statuses = array_map( 'trim', explode( ',', $args['status'] ) );
- $order_count = 0;
- foreach ( $statuses as $status ) {
- // if we didn't get a wc- prefix, add one
- if ( 0 !== strpos( $status, 'wc-' ) ) {
- $status = 'wc-' . $status;
- }
- $order_count += wp_count_posts( 'shop_order' )->$status;
- }
- ob_start();
- return '<span style="color:#fff;text-align:center;font-size:12px">Deals:' .
- $order_count;
- $user->total;
- return ob_get_clean();
- }
- add_shortcode( 'wc_order_count3', 'display_woocommerce_order_count2' );
- function get_instock_products_count(){
- global $wpdb;
- // The SQL query
- $result = $wpdb->get_col( "
- SELECT COUNT(p.ID)
- FROM {$wpdb->prefix}posts as p
- INNER JOIN {$wpdb->prefix}postmeta as pm ON p.ID = pm.post_id
- WHERE p.post_type LIKE '%product%'
- AND p.post_status LIKE 'publish'
- AND pm.meta_key LIKE '_stock_status'
- AND pm.meta_value LIKE 'instock'
- " );
- return '<span style="color:#fff;text-align:center;font-size:12px">Proposals
- Left: ' . reset($result);
- }
- add_shortcode('fp7', 'get_instock_products_count');
- function new_proposals2(){
- global $wpdb;
- // 24 hours ago
- $is_24h_ago = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")." -1day"));
- // The SQL query
- $result = $wpdb->get_col( "
- SELECT COUNT(p.ID)
- FROM {$wpdb->prefix}posts as p
- WHERE p.post_type LIKE '%product%'
- AND p.post_status LIKE 'publish'
- AND p.post_date > '$is_24h_ago'
- " );
- return '<span style="color:#fff;text-align:center;font-size:12px">New
- Proposals: ' . reset($result);
- }
- add_shortcode( 'new_proposals', 'new_proposals2' );
- function order_multi_count( $atts, $content = null ) {
- global $wpdb;
- $args = shortcode_atts( array(
- 'status' => 'completed',
- ), $atts );
- ## ---- ---- ---- ---- ---- ---- TAKEN ---- ---- ---- ---- ---- ---- ---- ##
- $statuses = array_map( 'trim', explode( ',', $args['status'] ) );
- $taken = 0;
- foreach ( $statuses as $status ) {
- // if we didn't get a wc- prefix, add one
- if ( 0 !== strpos( $status, 'wc-' ) ) {
- $status = 'wc-' . $status;
- }
- $taken += wp_count_posts( 'shop_order' )->$status;
- }
- ## ---- ---- ---- ---- ---- ---- LEFT ---- ---- ---- ---- ---- ---- ---- ##
- // The SQL query
- $result = $wpdb->get_col( "
- SELECT COUNT(p.ID)
- FROM {$wpdb->prefix}posts as p
- INNER JOIN {$wpdb->prefix}postmeta as pm ON p.ID = pm.post_id
- WHERE p.post_type LIKE '%product%'
- AND p.post_status LIKE 'publish'
- AND pm.meta_key LIKE '_stock_status'
- AND pm.meta_value LIKE 'instock'
- " );
- $left = reset($result);
- ## ---- ---- ---- ---- ---- ---- NEW ---- ---- ---- ---- ---- ---- ---- ##
- // 24 hours ago
- $is_24h_ago = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")." -1day"));
- // The SQL query
- $result2 = $wpdb->get_col( "
- SELECT COUNT(p.ID)
- FROM {$wpdb->prefix}posts as p
- WHERE p.post_type LIKE '%product%'
- AND p.post_status LIKE 'publish'
- AND p.post_date > '$is_24h_ago'
- " );
- $new = reset($result2);
- ## ---- ---- ---- ---- ---- RETURNING VALUE ---- ---- ---- ---- ---- ---- ##
- $style = 'style="color:#fff;text-align:center;font-size:12px"';
- return "<span $style><strong>Proposals:</strong> Taken ($taken) | New ($new) | Left ($left)</span>";
- }
- add_shortcode( 'order_multi_count', 'order_multi_count' );
Add Comment
Please, Sign In to add comment