Advertisement
Guest User

Untitled

a guest
Jun 16th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function framemarket_listall_shops(){
  4.  
  5.     global $wpdb;
  6.  
  7.     $query = "SELECT blog_id FROM " . $wpdb->base_prefix . "blogs WHERE spam != '1' AND archived != '1' AND deleted != '1' AND public = '1' ORDER BY path";
  8.  
  9.  
  10.  
  11.     $blogs = $wpdb->get_results($query);
  12.  
  13.     $blogs = apply_filters( 'framemarket_list_shops', $blogs );
  14.  
  15.     ?>
  16.  
  17. <select name="shoplist" onchange="document.location.href=this.options[this.selectedIndex].value;">
  18.  
  19.     <option value=""><?php echo apply_filters('shop_drop_default_label', 'Visit a shop') ?></option>
  20.  
  21.     <?php
  22.  
  23.     foreach($blogs as $blog){
  24.  
  25.         $blog_details = get_blog_details($blog->blog_id);
  26.  
  27. ?>
  28.  
  29. <option value="<?php echo $blog_details->siteurl; ?>"> <?php echo $blog_details->blogname; ?></option>
  30.  
  31. <?php
  32.  
  33.     }
  34.  
  35. ?>
  36.  
  37.  </select>
  38.  
  39. <?php
  40.  
  41. }
  42.  
  43. // [mp_product_stock]
  44. function mp_product_stock_sc( $product_id ){
  45.    
  46.     $stock = get_post_meta($product_id, 'mp_inventory', true);
  47.     //return $stock[0];
  48.  
  49.     if ($stock[0] == 0 ) {echo "<pre>";
  50. print_r($stock);
  51. echo "</pre>";
  52.         return $stock[0];
  53.     } else {
  54.         return '';
  55.     }
  56. }
  57. //add_shortcode( 'mp_product_stock', 'mp_product_stock_sc' );
  58.    
  59.    
  60.  
  61. // output in a grid of 4 across
  62.  
  63. function framemarket_grid_mp_list_products( $echo = true, $paginate = '', $paged = '', $per_page = '', $order_by = '', $order = '', $category = '', $tag = '', $search = '' ) {
  64.  
  65.   global $wp_query, $mp, $grid_home;
  66.  
  67.   $settings = get_option('mp_settings');
  68.  
  69.  
  70.  
  71.   //setup taxonomy if applicable
  72.  
  73.   $taxonomy_query = '';
  74.  
  75.   if ($category) {
  76.  
  77.     $taxonomy_query = '&product_category=' . sanitize_title($category);
  78.  
  79.   } else if ($tag) {
  80.  
  81.     $taxonomy_query = '&product_tag=' . sanitize_title($tag);
  82.  
  83.   } else if (isset($wp_query->query_vars['taxonomy']) && ($wp_query->query_vars['taxonomy'] == 'product_category' || $wp_query->query_vars['taxonomy'] == 'product_tag')) {
  84.  
  85.     $taxonomy_query = '&' . $wp_query->query_vars['taxonomy'] . '=' . get_query_var($wp_query->query_vars['taxonomy']);
  86.  
  87.   }
  88.  
  89.  
  90.  
  91.   //check if it's a search
  92.  
  93.   $search_query = '';
  94.  
  95.   if (isset($wp_query->query_vars['s']) && $wp_query->query_vars['s']){
  96.  
  97.     $search_query = '&s=' . $wp_query->query_vars['s'];
  98.  
  99.   }
  100.  
  101.  
  102.  
  103.     if ( $paginate ) {
  104.  
  105.         // $paged = true;
  106.  
  107.     } else if ( $paginate === '' ) {
  108.  
  109.         if ( $settings['paginate'] ) {
  110.  
  111.             //$paged = true;
  112.  
  113.         }
  114.  
  115.         else
  116.  
  117.             $paginate_query = '&nopaging=true';
  118.  
  119.     } else {
  120.  
  121.         $paginate_query = '&nopaging=true';
  122.  
  123.     }
  124.  
  125.  
  126.  
  127.     if (! $paged) {
  128.  
  129.         $paged = ( $wp_query->query_vars['paged'] ) ? $wp_query->query_vars['paged'] : 1;
  130.  
  131.     }
  132.  
  133.  
  134.  
  135.     //get page details
  136.  
  137.     if ( $paged ) {
  138.  
  139.         //figure out perpage
  140.  
  141.         if ( intval( $per_page ) )
  142.  
  143.           $paginate_query = '&posts_per_page='.intval($per_page);
  144.  
  145.         else
  146.  
  147.           $paginate_query = '&posts_per_page='.$settings['per_page'];
  148.  
  149.  
  150.  
  151.         //figure out page
  152.  
  153.         //if ( $wp_query->query_vars['paged'] )
  154.  
  155.         //  $paginate_query .= '&paged='.intval($wp_query->query_vars['paged']);
  156.  
  157.  
  158.  
  159.         if ( intval( $paged ) )
  160.  
  161.             $paginate_query .= '&paged='.intval($paged);
  162.  
  163.         else if ($wp_query->query_vars['paged'])
  164.  
  165.             $paginate_query .= '&paged='.intval($wp_query->query_vars['paged']);
  166.  
  167.         /*else if ($paged)
  168.  
  169.             $paginate_query .= '&paged='.intval($paged);*/
  170.  
  171.     }
  172.  
  173.  
  174.  
  175.   //get order by
  176.  
  177.   if (!$order_by) {
  178.  
  179.     if ($settings['order_by'] == 'price')
  180.  
  181.       $order_by_query = '&meta_key=mp_price_sort&orderby=meta_value_num';
  182.  
  183.     else if ($settings['order_by'] == 'sales')
  184.  
  185.       $order_by_query = '&meta_key=mp_sales_count&orderby=meta_value_num';
  186.  
  187.     else
  188.  
  189.       $order_by_query = '&orderby='.$settings['order_by'];
  190.  
  191.   } else {
  192.  
  193.     if ('price' == $order_by)
  194.  
  195.         $order_by_query = '&meta_key=mp_price_sort&orderby=meta_value_num';
  196.  
  197.     else if('sales' == $order_by)
  198.  
  199.       $order_by_query = '&meta_key=mp_sales_count&orderby=meta_value_num';
  200.  
  201.     else
  202.  
  203.         $order_by_query = '&orderby='.$order_by;
  204.  
  205.   }
  206.  
  207.  
  208.  
  209.   //get order direction
  210.  
  211.   if (!$order) {
  212.  
  213.     $order_query = '&order='.$settings['order'];
  214.  
  215.   } else {
  216.  
  217.     $order_query = '&order='.$order;
  218.  
  219.   }
  220.  
  221.  
  222.   //The Query
  223.  
  224.   $custom_query = new WP_Query('post_type=product&post_status=publish' . $search_query . $taxonomy_query . $paginate_query . $order_by_query . $order_query);
  225.  
  226.   $wp_query = $custom_query;
  227.  
  228.   $content = '<div id="mp_product_list">';
  229.  
  230.  
  231.  
  232.   if ($last = count($custom_query->posts)) {
  233.  
  234.  
  235.  
  236.     $count = 1;
  237.  
  238.     $counter = 0;
  239.  
  240.     foreach ($custom_query->posts as $post) {
  241.  
  242.  
  243.  
  244.             //add last css class for styling grids
  245.  
  246.             if (($count%5 == 0))
  247.  
  248.                  $class = array('mp_product', 'last-product');
  249.  
  250.             else
  251.  
  252.                  $class = 'mp_product';
  253.  
  254.  
  255.  
  256.       $content .= '<div '.mp_product_class(false, $class, $post->ID).'>';
  257.      
  258.       $content .= '<div class="mp_product_meta">';
  259.  
  260.       //price
  261.  
  262.       $meta = mp_product_price(false, $post->ID, false);
  263.      
  264.  
  265.       //button
  266.  
  267.       $meta .= mp_buy_button(false, 'list', $post->ID);
  268.      
  269.       $meta .= '<span class="original-sold">' . mp_product_stock_sc( $post->ID ) . '</span>';    
  270.  
  271.      
  272.  
  273.       $content .= apply_filters( 'mp_product_list_meta', $meta, $post->ID );
  274.  
  275.       $content .= '</div>';
  276.  
  277.       $content .= '<div class="mp_product_content">';
  278.      
  279.       $product_content = mp_product_image( false, 'list', $post->ID );
  280.      
  281.  
  282.       if( $mp->get_setting('show_excerpt') == 1 )
  283.  
  284.     $product_content .= $mp->product_excerpt($post->post_excerpt, $post->post_content, $post->ID);
  285.  
  286.       $content .= apply_filters( 'mp_product_list_content', $product_content, $post->ID );
  287.      
  288.       $content .= '<h3 class="mp_product_name"><a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a></h3>';
  289.  
  290.       $content .= '</div>';
  291.  
  292.       $content .= '</div>';
  293.  
  294.  
  295.  
  296.       $count++;
  297.  
  298.       $counter++;
  299.  
  300.         //add last css class for styling grids
  301.  
  302.       if (($counter%5 == 0))
  303.  
  304.             $content .= '<div class="clear"></div>';
  305.  
  306.     }
  307.  
  308.   } else {
  309.  
  310.     $content .= '<div id="mp_no_products">' . apply_filters( 'mp_product_list_none', __('No Products', 'mp') ) . '</div>';
  311.  
  312.   }
  313.  
  314.  
  315.  
  316.   $content .= '</div>';
  317.  
  318.  
  319.  
  320.     if (  $wp_query->max_num_pages > 1 ) :
  321.  
  322.         $content .= '<div id="navigation-bottom" class="navigation">';
  323.  
  324.         if (  $wp_query->query_vars['paged'] > 1 ) {
  325.  
  326.             if ($grid_home) {
  327.  
  328.                 $content .= '<div class="nav-previous"><a href="?page='.($wp_query->query_vars['paged']-1).'" >'. __('<span class="meta-nav">&larr;</span> Previous', 'framemarket').'</a></div>';
  329.  
  330.             } else {
  331.  
  332.                 $content .= '<div class="nav-previous">'. get_previous_posts_link( __('<span class="meta-nav">&larr;</span> Previous', 'framemarket') ).'</a></div>';
  333.  
  334.             }
  335.  
  336.         }
  337.  
  338.         if (  $wp_query->max_num_pages > $wp_query->query_vars['paged'] ) {
  339.  
  340.             if ($grid_home) {
  341.  
  342.                 $content .= '<div class="nav-next"><a href="?page='.($wp_query->query_vars['paged']+1).'" >'. __('Next <span class="meta-nav">&rarr;</span>', 'framemarket' ).'</a></div>';
  343.  
  344.             } else {
  345.  
  346.                 $content .= '<div class="nav-next">'. get_next_posts_link(__('Next <span class="meta-nav">&rarr;</span>', 'framemarket' )).'</div>';
  347.  
  348.             }
  349.  
  350.         }
  351.  
  352.         $content .= '</div>';
  353.  
  354.     endif;
  355.  
  356.  
  357.  
  358.     if ( $echo )
  359.  
  360.         echo $content;
  361.  
  362.     else
  363.  
  364.         return $content;
  365.  
  366. }
  367.  
  368.  
  369.  
  370. function framemarket_mp_list_global_products($args = '') {
  371.  
  372.   global $wpdb, $mp, $grid_home;
  373.  
  374.  
  375.  
  376.   $defaults = array(
  377.  
  378.         'echo' => true,
  379.  
  380.     'paginate' => true,
  381.  
  382.         'page' => 1,
  383.  
  384.     'per_page' => 20,
  385.  
  386.         'order_by' => 'date',
  387.  
  388.     'order' => 'DESC',
  389.  
  390.         'category' => '',
  391.  
  392.     'tag' => '',
  393.  
  394.         's' => '',
  395.  
  396.         'sentence' => '',
  397.  
  398.         'exact' => '',
  399.  
  400.         'show_thumbnail' => true,
  401.  
  402.         'thumbnail_size' => 150,
  403.  
  404.         'context' => 'list',
  405.  
  406.         'show_price' => true,
  407.  
  408.         'text' => 'excerpt',
  409.  
  410.         'as_list' => false
  411.  
  412.     );
  413.  
  414.  
  415.  
  416.   $r = wp_parse_args( $args, $defaults );
  417.  
  418.   extract( $r );
  419.  
  420.  
  421.  
  422.   //setup taxonomy if applicable
  423.  
  424.   if ($category) {
  425.  
  426.     $category = $wpdb->escape( sanitize_title( $category ) );
  427.  
  428.     $query = "SELECT blog_id, p.post_id, post_permalink, post_title, post_content FROM {$wpdb->base_prefix}mp_products p INNER JOIN {$wpdb->base_prefix}mp_term_relationships r ON p.id = r.post_id INNER JOIN {$wpdb->base_prefix}mp_terms t ON r.term_id = t.term_id WHERE p.blog_public = 1 AND t.type = 'product_category' AND t.slug = '$category'";
  429.  
  430.     $query_count = "SELECT COUNT(*) FROM {$wpdb->base_prefix}mp_products p INNER JOIN {$wpdb->base_prefix}mp_term_relationships r ON p.id = r.post_id INNER JOIN {$wpdb->base_prefix}mp_terms t ON r.term_id = t.term_id WHERE p.blog_public = 1 AND t.type = 'product_category' AND t.slug = '$category'";
  431.  
  432.   } else if ($tag) {
  433.  
  434.     $tag = $wpdb->escape( sanitize_title( $tag ) );
  435.  
  436.     $query = "SELECT blog_id, p.post_id, post_permalink, post_title, post_content FROM {$wpdb->base_prefix}mp_products p INNER JOIN {$wpdb->base_prefix}mp_term_relationships r ON p.id = r.post_id INNER JOIN {$wpdb->base_prefix}mp_terms t ON r.term_id = t.term_id WHERE p.blog_public = 1 AND t.type = 'product_tag' AND t.slug = '$tag'";
  437.  
  438.     $query_count = "SELECT COUNT(*) FROM {$wpdb->base_prefix}mp_products p INNER JOIN {$wpdb->base_prefix}mp_term_relationships r ON p.id = r.post_id INNER JOIN {$wpdb->base_prefix}mp_terms t ON r.term_id = t.term_id WHERE p.blog_public = 1 AND t.type = 'product_tag' AND t.slug = '$tag'";
  439.  
  440.   } else {
  441.  
  442.     $query = "SELECT blog_id, p.post_id, post_permalink, post_title, post_content FROM {$wpdb->base_prefix}mp_products p WHERE p.blog_public = 1";
  443.  
  444.     $query_count = "SELECT COUNT(*) FROM {$wpdb->base_prefix}mp_products p WHERE p.blog_public = 1";
  445.  
  446.   }
  447.  
  448.  
  449.  
  450.     // get search
  451.  
  452.     if ( !empty($s) ) {
  453.  
  454.         // added slashes screw with quote grouping when done early, so done later
  455.  
  456.         $s = stripslashes($s);
  457.  
  458.         if ( !empty($sentence) ) {
  459.  
  460.             $search_terms = array($s);
  461.  
  462.         } else {
  463.  
  464.             preg_match_all('/".*?("|$)|((?<=[\r\n\t ",+])|^)[^\r\n\t ",+]+/', $s, $matches);
  465.  
  466.             $search_terms = array_map('_search_terms_tidy', $matches[0]);
  467.  
  468.         }
  469.  
  470.         $n = !empty($exact) ? '' : '%';
  471.  
  472.         $search = '';
  473.  
  474.         $searchand = '';
  475.  
  476.         foreach( (array) $search_terms as $term ) {
  477.  
  478.             $term = esc_sql( like_escape( $term ) );
  479.  
  480.             $search .= "{$searchand}((p.post_title LIKE '{$n}{$term}{$n}') OR (p.post_content LIKE '{$n}{$term}{$n}'))";
  481.  
  482.             $searchand = ' AND ';
  483.  
  484.         }
  485.  
  486.         if ( !empty($search) ) {
  487.  
  488.             $query .= " AND ({$search}) ";
  489.  
  490.         }
  491.  
  492.     }
  493.  
  494.  
  495.  
  496.   //get order by
  497.  
  498.   switch ($order_by) {
  499.  
  500.  
  501.  
  502.     case 'title':
  503.  
  504.       $query .= " ORDER BY p.post_title";
  505.  
  506.       break;
  507.  
  508.  
  509.  
  510.     case 'price':
  511.  
  512.       $query .= " ORDER BY p.price";
  513.  
  514.       break;
  515.  
  516.  
  517.  
  518.     case 'sales':
  519.  
  520.       $query .= " ORDER BY p.sales_count";
  521.  
  522.       break;
  523.  
  524.  
  525.  
  526.     case 'rand':
  527.  
  528.       $query .= " ORDER BY RAND()";
  529.  
  530.       break;
  531.  
  532.  
  533.  
  534.     case 'date':
  535.  
  536.     default:
  537.  
  538.       $query .= " ORDER BY p.post_date";
  539.  
  540.       break;
  541.  
  542.   }
  543.  
  544.  
  545.  
  546.   //get order direction
  547.  
  548.   if ($order == 'ASC') {
  549.  
  550.     $query .= " ASC";
  551.  
  552.   } else {
  553.  
  554.     $query .= " DESC";
  555.  
  556.   }
  557.  
  558.  
  559.  
  560.   //get page details
  561.  
  562.   if ($paginate)
  563.  
  564.     $query .= " LIMIT " . intval(($page-1)*$per_page) . ", " . intval($per_page);
  565.  
  566.  
  567.  
  568.   //The Query
  569.  
  570.   $results = $wpdb->get_results( $query );
  571.  
  572.   if ($paginate){
  573.  
  574.       $total_results = $wpdb->get_var( $query_count );
  575.  
  576.       $total_pages = ceil($total_results/$per_page);
  577.  
  578.   }
  579.  
  580.  
  581.  
  582.   // Make sure show thumbnail setting follow main site
  583.  
  584.   $show_thumbnail = ( !$mp->get_setting('show_thumbnail') ) ? false : $show_thumbnail;
  585.  
  586.  
  587.  
  588.    $content = '<div id="mp_product_list">';
  589.  
  590.  
  591.  
  592.   if ($results) {
  593.  
  594.     $count = 1;
  595.  
  596.     $counter = 0;
  597.  
  598.     foreach ($results as $product) {
  599.  
  600.  
  601.  
  602.             //add last css class for styling grids
  603.  
  604.             if (($count%4 == 0))
  605.  
  606.                  $content .= '<div class="product mp_product last-product">';
  607.  
  608.             else
  609.  
  610.                   $content .= '<div class="product mp_product">';
  611.  
  612.  
  613.  
  614.  
  615.  
  616.       global $current_blog;
  617.  
  618.       switch_to_blog($product->blog_id);
  619.  
  620.  
  621.  
  622.       //grab permalink
  623.  
  624.       $permalink = get_permalink( $product->post_id );
  625.  
  626.  
  627.  
  628.       //grab thumbnail
  629.  
  630.       if ($show_thumbnail)
  631.  
  632.         $thumbnail = mp_product_image( false, $context, $product->post_id, $thumbnail_size );
  633.  
  634.  
  635.  
  636.       //price
  637.  
  638.       if ($show_price) {
  639.  
  640.         if ($context == 'widget')
  641.  
  642.           $price = mp_product_price(false, $product->post_id, ''); //no price label in widgets
  643.  
  644.         else
  645.  
  646.           $price = mp_product_price(false, $product->post_id, '');
  647.  
  648.       }
  649.  
  650.  
  651.  
  652.       restore_current_blog();
  653.  
  654.  
  655.  
  656.       $content .= '<h3 class="mp_product_name"><a href="' . $permalink . '">' . esc_attr($product->post_title) . '</a></h3>';
  657.  
  658.       $content .= '<div class="mp_product_content">';
  659.  
  660.  
  661.  
  662.       $content .= $thumbnail;
  663.  
  664.  
  665.  
  666.       $content .= '</div>';
  667.  
  668.  
  669.  
  670.       $content .= '<div class="mp_product_meta">';
  671.  
  672.  
  673.  
  674.       //price
  675.  
  676.       $content .= $price;
  677.  
  678.  
  679.  
  680.       //button
  681.  
  682.       $content .= '<a class="mp_link_buynow" href="' . $permalink . '">' .  __('Buy Now &raquo;', 'mp') . '</a>';
  683.  
  684.       $content .= '</div>';
  685.  
  686.  
  687.  
  688.         $content .= '</div>';
  689.  
  690.          $count++;
  691.  
  692.           $counter++;
  693.  
  694.             //add last css class for styling grids
  695.  
  696.           if (($counter%4 == 0))
  697.  
  698.                 $content .= '<div class="clear"></div>';
  699.  
  700.     }
  701.  
  702.   } else {
  703.  
  704.     $content .= '<div id="mp_no_products">' . apply_filters( 'mp_product_list_none', __('No Products', 'mp') ) . '</div>';
  705.  
  706.   }
  707.  
  708.  
  709.  
  710.     // Pagination
  711.  
  712.     if ( $paginate ){
  713.  
  714.         if ( $total_pages > 0 ){
  715.  
  716.             $content .= '<div id="navigation-bottom" class="navigation">';
  717.  
  718.             if (  $page > 1 ) {
  719.  
  720.                 if ($grid_home) {
  721.  
  722.                     $content .= '<div class="nav-previous"><a href="?page='.($page-1).'" >'. __('<span class="meta-nav">&larr;</span> Previous', 'framemarket').'</a></div>';
  723.  
  724.                 } else {
  725.  
  726.                     $content .= '<div class="nav-previous">'. get_previous_posts_link( __('<span class="meta-nav">&larr;</span> Previous', 'framemarket'), $total_pages ).'</a></div>';
  727.  
  728.                 }
  729.  
  730.             }
  731.  
  732.             if (  $total_pages > $page ) {
  733.  
  734.                 if ($grid_home) {
  735.  
  736.                     $content .= '<div class="nav-next"><a href="?page='.($page+1).'" >'. __('Next <span class="meta-nav">&rarr;</span>', 'framemarket' ).'</a></div>';
  737.  
  738.                 } else {
  739.  
  740.                     $content .= '<div class="nav-next">'. get_next_posts_link(__('Next <span class="meta-nav">&rarr;</span>', 'framemarket' ), $total_pages).'</div>';
  741.  
  742.                 }
  743.  
  744.             }
  745.  
  746.             $content .= '</div>';
  747.  
  748.         }
  749.  
  750.     }
  751.  
  752.  
  753.  
  754.     $content .= '</div>';
  755.  
  756.  
  757.  
  758.   if ($echo)
  759.  
  760.     echo $content;
  761.  
  762.   else
  763.  
  764.     return $content;
  765.  
  766. }
  767.  
  768.  
  769.  
  770. function framemarket_mp_list_categories( $echo = true, $args = '' ) {
  771.  
  772.   $args['taxonomy'] = 'product_category';
  773.  
  774.   $args['echo'] = false;
  775.  
  776.   $args['title_li'] = '';
  777.  
  778.  
  779.  
  780.   $list = '<ul id="mp_category_list">' . wp_list_categories( $args ) . '</ul>';
  781.  
  782.  
  783.  
  784.   if ($echo)
  785.  
  786.     echo $list;
  787.  
  788.   else
  789.  
  790.     return $list;
  791.  
  792. }
  793.  
  794.  
  795.  
  796. function framemarket_global_categories_theme($content) {
  797.  
  798.   global $wp_query;
  799.  
  800.  
  801.  
  802.   if ( $slug = get_query_var('global_taxonomy') ) {
  803.  
  804.     $args = array();
  805.  
  806.     $args['echo'] = false;
  807.  
  808.     $args['category'] = $slug;
  809.  
  810.  
  811.  
  812.     //check for paging
  813.  
  814.     if (get_query_var('paged'))
  815.  
  816.       $args['page'] = intval(get_query_var('paged'));
  817.  
  818.  
  819.  
  820.     $content = framemarket_mp_list_global_products( $args );
  821.  
  822.     $content .= get_posts_nav_link();
  823.  
  824.  
  825.  
  826.   } else { //no category set, so show list
  827.  
  828.     $content .= mp_global_categories_list( array( 'echo' => false ) );
  829.  
  830.   }
  831.  
  832.  
  833.  
  834.   return $content;
  835.  
  836. }
  837.  
  838.  
  839.  
  840. function framemarket_product_meta() {
  841.  
  842.    global $post, $id;
  843.  
  844.    $post_id = ( NULL === $post->ID ) ? $id : $post->ID;
  845.  
  846.  
  847.  
  848.    //don't filter outside of the loop
  849.  
  850.     if ( !in_the_loop() )
  851.  
  852.           return $content;
  853.  
  854.  
  855.  
  856.    $content = '<div class="product-meta-details">';
  857.  
  858.    $content .= mp_category_list($post_id, '<span class="grid_mp_product_categories">' . __( 'Categorized in ', 'mp' ), ', ', '</span>');
  859.  
  860.    $content .= '&nbsp;&nbsp;';
  861.  
  862.    $content .= mp_tag_list($post_id, '<span class="grid_mp_product_tags">'.__('Tagged in ', 'mp'), ', ', '</span>');
  863.  
  864.    $content .= '</div><hr/><div class="product-meta-details">';
  865.  
  866.    $content .= mp_product_price(false);
  867.  
  868.    $content .= mp_pinit_button();
  869.  
  870.    $content .= mp_buy_button(false, 'single');
  871.  
  872.    $content .= '</div><hr />';
  873.  
  874.  
  875.  
  876.    return $content;
  877.  
  878.  }
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886. function framemarket_mp_order_status() {
  887.  
  888.   global $mp, $wp_query;
  889.  
  890.     $settings = get_option('mp_settings');
  891.  
  892.   echo $settings['msg']['order_status'];
  893.  
  894.  
  895.  
  896.   $order_id = ($wp_query->query_vars['order_id']) ? $wp_query->query_vars['order_id'] : $_GET['order_id'];
  897.  
  898.  
  899.  
  900.   if (!empty($order_id)) {
  901.  
  902.     //get order
  903.  
  904.     $order = $mp->get_order($order_id);
  905.  
  906.  
  907.  
  908.     if ($order) { //valid order
  909.  
  910.       echo '<hr/><h2><em>' . sprintf( __('Order Details (%s):', 'mp'), htmlentities($order_id)) . '</em></h2>';
  911.  
  912.       ?>
  913.  
  914.       <h3><?php _e('Current Status', 'mp'); ?></h3>
  915.  
  916.       <ul>
  917.  
  918.       <?php
  919.  
  920.       //get times
  921.  
  922.       $received = date(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_received_time);
  923.  
  924.       if ($order->mp_paid_time)
  925.  
  926.         $paid = date(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_paid_time);
  927.  
  928.       if ($order->mp_shipped_time)
  929.  
  930.         $shipped = date(get_option('date_format') . ' - ' . get_option('time_format'), $order->mp_shipped_time);
  931.  
  932.  
  933.  
  934.       if ($order->post_status == 'order_received') {
  935.  
  936.         echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>';
  937.  
  938.       } else if ($order->post_status == 'order_paid') {
  939.  
  940.         echo '<li>' . __('Paid:', 'mp') . ' <strong>' . $paid . '</strong></li>';
  941.  
  942.         echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>';
  943.  
  944.       } else if ($order->post_status == 'order_shipped' || $order->post_status == 'order_closed') {
  945.  
  946.         echo '<li>' . __('Shipped:', 'mp') . ' <strong>' . $shipped . '</strong></li>';
  947.  
  948.         echo '<li>' . __('Paid:', 'mp') . ' <strong>' . $paid . '</strong></li>';
  949.  
  950.         echo '<li>' . __('Received:', 'mp') . ' <strong>' . $received . '</strong></li>';
  951.  
  952.       }
  953.  
  954.  
  955.  
  956.       $order_paid = $order->post_status != 'order_received';
  957.  
  958.       $max_downloads = intval($settings['max_downloads']) ? intval($settings['max_downloads']) : 5;
  959.  
  960.       ?>
  961.  
  962.       </ul>
  963.  
  964. <hr/>
  965.  
  966.       <h3><?php _e('Payment Information:', 'mp'); ?></h3>
  967.  
  968.       <ul>
  969.  
  970.         <li>
  971.  
  972.           <?php _e('Payment Method:', 'mp'); ?>
  973.  
  974.           <strong><?php echo $order->mp_payment_info['gateway_public_name']; ?></strong>
  975.  
  976.         </li>
  977.  
  978.         <li>
  979.  
  980.           <?php _e('Payment Type:', 'mp'); ?>
  981.  
  982.           <strong><?php echo $order->mp_payment_info['method']; ?></strong>
  983.  
  984.         </li>
  985.  
  986.         <li>
  987.  
  988.           <?php _e('Transaction ID:', 'mp'); ?>
  989.  
  990.           <strong><?php echo $order->mp_payment_info['transaction_id']; ?></strong>
  991.  
  992.         </li>
  993.  
  994.         <li>
  995.  
  996.           <?php _e('Payment Total:', 'mp'); ?>
  997.  
  998.           <strong><?php echo $mp->format_currency($order->mp_payment_info['currency'], $order->mp_payment_info['total']) . ' ' . $order->mp_payment_info['currency']; ?></strong>
  999.  
  1000.         </li>
  1001.  
  1002.       </ul>
  1003.  
  1004.  
  1005.  
  1006. <hr/>
  1007.  
  1008.       <h3><?php _e('Order Information:', 'mp'); ?></h3>
  1009.  
  1010.       <table id="mp-order-product-table" class="mp_cart_contents">
  1011.  
  1012.         <thead><tr>
  1013.  
  1014.           <th class="mp_cart_col_thumb">&nbsp;</th>
  1015.  
  1016.           <th class="mp_cart_col_product"><?php _e('Item', 'mp'); ?></th>
  1017.  
  1018.           <th class="mp_cart_col_quant"><?php _e('Quantity', 'mp'); ?></th>
  1019.  
  1020.           <th class="mp_cart_col_price"><?php _e('Price', 'mp'); ?></th>
  1021.  
  1022.           <th class="mp_cart_col_subtotal"><?php _e('Subtotal', 'mp'); ?></th>
  1023.  
  1024.           <th class="mp_cart_col_downloads"><?php _e('Download', 'mp'); ?></th>
  1025.  
  1026.         </tr></thead>
  1027.  
  1028.         <tbody>
  1029.  
  1030.         <?php
  1031.  
  1032.           if (is_array($order->mp_cart_info) && count($order->mp_cart_info)) {
  1033.  
  1034.                         foreach ($order->mp_cart_info as $product_id => $variations) {
  1035.  
  1036.                             //for compatibility for old orders from MP 1.x
  1037.  
  1038.                             if (isset($variations['name'])) {
  1039.  
  1040.                 $data = $variations;
  1041.  
  1042.                 echo '<tr>';
  1043.  
  1044.                   echo '  <td class="mp_cart_col_thumb">' . mp_product_image( false, 'widget', $product_id ) . '</td>';
  1045.  
  1046.                   echo '  <td class="mp_cart_col_product"><a href="' . get_permalink($product_id) . '">' . esc_attr($data['name']) . '</a></td>';
  1047.  
  1048.                   echo '  <td class="mp_cart_col_quant">' . number_format_i18n($data['quantity']) . '</td>';
  1049.  
  1050.                   echo '  <td class="mp_cart_col_price">' . $mp->format_currency('', $data['price']) . '</td>';
  1051.  
  1052.                   echo '  <td class="mp_cart_col_subtotal">' . $mp->format_currency('', $data['price'] * $data['quantity']) . '</td>';
  1053.  
  1054.                   echo '  <td class="mp_cart_col_downloads"></td>';
  1055.  
  1056.                   echo '</tr>';
  1057.  
  1058.                             } else {
  1059.  
  1060.                                 foreach ($variations as $variation => $data) {
  1061.  
  1062.                       echo '<tr>';
  1063.  
  1064.                       echo '  <td class="mp_cart_col_thumb">' . mp_product_image( false, 'widget', $product_id ) . '</td>';
  1065.  
  1066.                       echo '  <td class="mp_cart_col_product"><a href="' . get_permalink($product_id) . '">' . esc_attr($data['name']) . '</a></td>';
  1067.  
  1068.                       echo '  <td class="mp_cart_col_quant">' . number_format_i18n($data['quantity']) . '</td>';
  1069.  
  1070.                       echo '  <td class="mp_cart_col_price">' . $mp->format_currency('', $data['price']) . '</td>';
  1071.  
  1072.                       echo '  <td class="mp_cart_col_subtotal">' . $mp->format_currency('', $data['price'] * $data['quantity']) . '</td>';
  1073.  
  1074.                                     if (is_array($data['download']) && $download_url = $mp->get_download_url($product_id, $order->post_title)) {
  1075.  
  1076.                     if ($order_paid) {
  1077.  
  1078.                       //check for too many downloads
  1079.  
  1080.                                             if (intval($data['download']['downloaded']) < $max_downloads)
  1081.  
  1082.                                                 echo '  <td class="mp_cart_col_downloads"><a href="' . $download_url . '">' . __('Download&raquo;', 'mp') . '</a></td>';
  1083.  
  1084.                                             else
  1085.  
  1086.                                               echo '  <td class="mp_cart_col_downloads">' . __('Limit Reached', 'mp') . '</td>';
  1087.  
  1088.                                         } else {
  1089.  
  1090.                                           echo '  <td class="mp_cart_col_downloads">' . __('Awaiting Payment', 'mp') . '</td>';
  1091.  
  1092.                                         }
  1093.  
  1094.                                     } else {
  1095.  
  1096.                                         echo '  <td class="mp_cart_col_downloads"></td>';
  1097.  
  1098.                                     }
  1099.  
  1100.                       echo '</tr>';
  1101.  
  1102.                                 }
  1103.  
  1104.                             }
  1105.  
  1106.             }
  1107.  
  1108.           } else {
  1109.  
  1110.             echo '<tr><td colspan="6">' . __('No products could be found for this order', 'mp') . '</td></tr>';
  1111.  
  1112.           }
  1113.  
  1114.           ?>
  1115.  
  1116.         </tbody>
  1117.  
  1118.       </table>
  1119.  
  1120.       <ul>
  1121.  
  1122.         <?php //coupon line
  1123.  
  1124.         if ( $order->mp_discount_info ) { ?>
  1125.  
  1126.         <li><?php _e('Coupon Discount:', 'mp'); ?> <strong><?php echo $order->mp_discount_info['discount']; ?></strong></li>
  1127.  
  1128.         <?php } ?>
  1129.  
  1130.  
  1131.  
  1132.         <?php //shipping line
  1133.  
  1134.         if ( $order->mp_shipping_total ) { ?>
  1135.  
  1136.         <li><?php _e('Shipping:', 'mp'); ?> <strong><?php echo $mp->format_currency('', $order->mp_shipping_total); ?></strong></li>
  1137.  
  1138.         <?php } ?>
  1139.  
  1140.  
  1141.  
  1142.         <?php //tax line
  1143.  
  1144.         if ( $order->mp_tax_total ) { ?>
  1145.  
  1146.         <li><?php _e('Taxes:', 'mp'); ?> <strong><?php echo $mp->format_currency('', $order->mp_tax_total); ?></strong></li>
  1147.  
  1148.         <?php } ?>
  1149.  
  1150.  
  1151.  
  1152.         <li><?php _e('Order Total:', 'mp'); ?> <strong><?php echo $mp->format_currency('', $order->mp_order_total); ?></strong></li>
  1153.  
  1154.       </ul>
  1155.  
  1156. <hr/>
  1157.  
  1158.       <h3><?php _e('Shipping Information:', 'mp'); ?></h3>
  1159.  
  1160.       <table>
  1161.  
  1162.         <tr>
  1163.  
  1164.         <td align="right"><?php _e('Full Name:', 'mp'); ?></td><td>
  1165.  
  1166.         <?php echo esc_attr($order->mp_shipping_info['name']); ?></td>
  1167.  
  1168.         </tr>
  1169.  
  1170.  
  1171.  
  1172.         <tr>
  1173.  
  1174.         <td align="right"><?php _e('Address:', 'mp'); ?></td>
  1175.  
  1176.         <td><?php echo esc_attr($order->mp_shipping_info['address1']); ?></td>
  1177.  
  1178.         </tr>
  1179.  
  1180.  
  1181.  
  1182.         <?php if ($order->mp_shipping_info['address2']) { ?>
  1183.  
  1184.         <tr>
  1185.  
  1186.         <td align="right"><?php _e('Address 2:', 'mp'); ?></td>
  1187.  
  1188.         <td><?php echo esc_attr($order->mp_shipping_info['address2']); ?></td>
  1189.  
  1190.         </tr>
  1191.  
  1192.         <?php } ?>
  1193.  
  1194.  
  1195.  
  1196.         <tr>
  1197.  
  1198.         <td align="right"><?php _e('City:', 'mp'); ?></td>
  1199.  
  1200.         <td><?php echo esc_attr($order->mp_shipping_info['city']); ?></td>
  1201.  
  1202.         </tr>
  1203.  
  1204.  
  1205.  
  1206.         <?php if ($order->mp_shipping_info['state']) { ?>
  1207.  
  1208.         <tr>
  1209.  
  1210.         <td align="right"><?php _e('State/Province/Region:', 'mp'); ?></td>
  1211.  
  1212.         <td><?php echo esc_attr($order->mp_shipping_info['state']); ?></td>
  1213.  
  1214.         </tr>
  1215.  
  1216.         <?php } ?>
  1217.  
  1218.  
  1219.  
  1220.         <tr>
  1221.  
  1222.         <td align="right"><?php _e('Postal/Zip Code:', 'mp'); ?></td>
  1223.  
  1224.         <td><?php echo esc_attr($order->mp_shipping_info['zip']); ?></td>
  1225.  
  1226.         </tr>
  1227.  
  1228.  
  1229.  
  1230.         <tr>
  1231.  
  1232.         <td align="right"><?php _e('Country:', 'mp'); ?></td>
  1233.  
  1234.         <td><?php echo $mp->countries[$order->mp_shipping_info['country']]; ?></td>
  1235.  
  1236.         </tr>
  1237.  
  1238.  
  1239.  
  1240.         <?php if ($order->mp_shipping_info['phone']) { ?>
  1241.  
  1242.         <tr>
  1243.  
  1244.         <td align="right"><?php _e('Phone Number:', 'mp'); ?></td>
  1245.  
  1246.         <td><?php echo esc_attr($order->mp_shipping_info['phone']); ?></td>
  1247.  
  1248.         </tr>
  1249.  
  1250.         <?php } ?>
  1251.  
  1252.       </table>
  1253.  
  1254.  
  1255.  
  1256.       <?php
  1257.  
  1258.     if (isset($order->mp_order_notes)) {
  1259.  
  1260.         echo '<div class="grid_mp_order_notes"><h3>' . apply_filters('mp_order_status_section_title_order_notes', __('Order Notes', 'mp'), $order) . '</h3>' .
  1261.  
  1262.             wpautop($order->mp_order_notes) . '</div>';
  1263.  
  1264.     }
  1265.  
  1266.       ?>
  1267.  
  1268.  
  1269.  
  1270.       <?php mp_orderstatus_link(true, false, __('&laquo; Back', 'mp')); ?>
  1271.  
  1272.       <?php
  1273.  
  1274.  
  1275.  
  1276.     } else { //not valid order id
  1277.  
  1278.       echo '<hr/><h3>' . __('Invalid Order ID. Please try again:', 'mp') . '</h3>';
  1279.  
  1280.       ?>
  1281.  
  1282.       <form action="<?php mp_orderstatus_link(true, true); ?>" method="get">
  1283.  
  1284.             <label><?php _e('Enter your 12-digit Order ID number:', 'mp'); ?><br />
  1285.  
  1286.             <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label>
  1287.  
  1288.             <input type="submit" id="order-id-submit" value="<?php _e('Look Up &raquo;', 'mp'); ?>" />
  1289.  
  1290.       </form>
  1291.  
  1292.       <?php
  1293.  
  1294.     }
  1295.  
  1296.  
  1297.  
  1298.   } else {
  1299.  
  1300.  
  1301.  
  1302.     //get from usermeta
  1303.  
  1304.     $user_id = get_current_user_id();
  1305.  
  1306.     if ($user_id) {
  1307.  
  1308.       if (is_multisite()) {
  1309.  
  1310.         global $blog_id;
  1311.  
  1312.         $meta_id = 'mp_order_history_' . $blog_id;
  1313.  
  1314.       } else {
  1315.  
  1316.         $meta_id = 'mp_order_history';
  1317.  
  1318.       }
  1319.  
  1320.       $orders = get_user_meta($user_id, $meta_id, true);
  1321.  
  1322.     } else {
  1323.  
  1324.       //get from cookie
  1325.  
  1326.       if (is_multisite()) {
  1327.  
  1328.         global $blog_id;
  1329.  
  1330.         $cookie_id = 'mp_order_history_' . $blog_id . '_' . COOKIEHASH;
  1331.  
  1332.       } else {
  1333.  
  1334.         $cookie_id = 'mp_order_history_' . COOKIEHASH;
  1335.  
  1336.       }
  1337.  
  1338.  
  1339.  
  1340.       if (isset($_COOKIE[$cookie_id]))
  1341.  
  1342.         $orders = unserialize($_COOKIE[$cookie_id]);
  1343.  
  1344.     }
  1345.  
  1346.  
  1347.  
  1348.     if (is_array($orders) && count($orders)) {
  1349.  
  1350.       krsort($orders);
  1351.  
  1352.       //list orders
  1353.  
  1354.       echo '<hr/><h3>' . __('Your Recent Orders:', 'mp') . '</h3>';
  1355.  
  1356.       echo '<ul id="mp-order-list">';
  1357.  
  1358.       foreach ($orders as $timestamp => $order)
  1359.  
  1360.         echo '  <li><strong>' . date(get_option('date_format') . ' - ' . get_option('time_format'), $timestamp) . ':</strong> <a href="./' . trailingslashit($order['id']) . '">' . $order['id'] . '</a> - ' . $mp->format_currency('', $order['total']) . '</li>';
  1361.  
  1362.       echo '</ul>';
  1363.  
  1364.  
  1365.  
  1366.       ?>
  1367.  
  1368.       <form action="<?php mp_orderstatus_link(true, true); ?>" method="get">
  1369.  
  1370.             <label><?php _e('Or enter your 12-digit Order ID number:', 'mp'); ?><br />
  1371.  
  1372.             <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label>
  1373.  
  1374.             <input type="submit" id="order-id-submit" value="<?php _e('Look Up &raquo;', 'mp'); ?>" />
  1375.  
  1376.       </form>
  1377.  
  1378.       <?php
  1379.  
  1380.  
  1381.  
  1382.     } else {
  1383.  
  1384.  
  1385.  
  1386.       if (!is_user_logged_in()) {
  1387.  
  1388.         ?>
  1389.  
  1390.         <table class="mp_cart_login">
  1391.  
  1392.           <thead><tr>
  1393.  
  1394.             <th class="mp_cart_login" colspan="2"><?php _e('Have a User Account? Login To View Your Order History:', 'mp'); ?></th>
  1395.  
  1396.             <th>&nbsp;</th>
  1397.  
  1398.           </tr></thead>
  1399.  
  1400.           <tbody>
  1401.  
  1402.           <tr>
  1403.  
  1404.             <td class="mp_cart_login">
  1405.  
  1406.               <form name="loginform" id="loginform" action="<?php echo wp_login_url(); ?>" method="post">
  1407.  
  1408.                     <label><?php _e('Username', 'mp'); ?><br />
  1409.  
  1410.                     <input type="text" name="log" id="user_login" class="input" value="" size="20" /></label>
  1411.  
  1412.                 <br />
  1413.  
  1414.                     <label><?php _e('Password', 'mp'); ?><br />
  1415.  
  1416.                     <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label>
  1417.  
  1418.                 <br />
  1419.  
  1420.                     <input type="submit" name="wp-submit" id="mp_login_submit" value="<?php _e('Login &raquo;', 'mp'); ?>" />
  1421.  
  1422.                     <input type="hidden" name="redirect_to" value="<?php mp_orderstatus_link(true, true); ?>" />
  1423.  
  1424.               </form>
  1425.  
  1426.             </td>
  1427.  
  1428.             <td class="mp_cart_or_label"><?php _e('or', 'mp'); ?></td>
  1429.  
  1430.             <td class="mp_cart_checkout">
  1431.  
  1432.               <form action="<?php mp_orderstatus_link(true, true); ?>" method="get">
  1433.  
  1434.                     <label><?php _e('Enter your 12-digit Order ID number:', 'mp'); ?><br />
  1435.  
  1436.                     <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label>
  1437.  
  1438.                     <input type="submit" id="order-id-submit" value="<?php _e('Look Up &raquo;', 'mp'); ?>" />
  1439.  
  1440.               </form>
  1441.  
  1442.             </td>
  1443.  
  1444.           </tr>
  1445.  
  1446.           </tbody>
  1447.  
  1448.         </table>
  1449.  
  1450.         <?php
  1451.  
  1452.       } else {
  1453.  
  1454.         ?>
  1455.  
  1456.         <form action="<?php mp_orderstatus_link(true, true); ?>" method="get">
  1457.  
  1458.             <label><?php _e('Enter your 12-digit Order ID number:', 'mp'); ?><br />
  1459.  
  1460.             <input type="text" name="order_id" id="order_id" class="input" value="" size="20" /></label>
  1461.  
  1462.             <input type="submit" id="order-id-submit" value="<?php _e('Look Up &raquo;', 'mp'); ?>" />
  1463.  
  1464.         </form>
  1465.  
  1466.         <?php
  1467.  
  1468.       }
  1469.  
  1470.  
  1471.  
  1472.     }
  1473.  
  1474.   }
  1475.  
  1476. }
  1477.  
  1478.  
  1479.  
  1480. function framemarket_page_title_output() {
  1481.  
  1482.     global $wp_query, $wpdb;
  1483.  
  1484.  
  1485.  
  1486.     //filter out nav titles
  1487.  
  1488.     if (!empty($title) && $id === false)
  1489.  
  1490.       return $title;
  1491.  
  1492.  
  1493.  
  1494.     if ( $slug = get_query_var('global_taxonomy') ) {
  1495.  
  1496.       $slug = $wpdb->escape( $slug );
  1497.  
  1498.       $name = $wpdb->get_var( "SELECT name FROM {$wpdb->base_prefix}mp_terms WHERE slug = '$slug'" );
  1499.  
  1500.     }
  1501.  
  1502.  
  1503.  
  1504.     switch ($wp_query->query_vars['pagename']) {
  1505.  
  1506.       case 'mp_global_products':
  1507.  
  1508.         return __('Marketplace Products', 'mp');
  1509.  
  1510.         break;
  1511.  
  1512.  
  1513.  
  1514.       case 'mp_global_categories':
  1515.  
  1516.         if ($name)
  1517.  
  1518.           return sprintf( __('Product Category: %s', 'mp'), esc_attr($name) );
  1519.  
  1520.         else
  1521.  
  1522.           return __('Marketplace Product Categories', 'mp');
  1523.  
  1524.         break;
  1525.  
  1526.  
  1527.  
  1528.       case 'mp_global_tags':
  1529.  
  1530.         if ($name)
  1531.  
  1532.           return sprintf( __('Product Tag: %s', 'mp'), esc_attr($name) );
  1533.  
  1534.         else
  1535.  
  1536.           return __('Marketplace Product Tags', 'mp');
  1537.  
  1538.         break;
  1539.  
  1540.  
  1541.  
  1542.       default:
  1543.  
  1544.        return '';
  1545.  
  1546.     }
  1547.  
  1548.   }
  1549.  
  1550. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement