Skip to content

Instantly share code, notes, and snippets.

@logichub
Last active February 10, 2019 00:32
Show Gist options
  • Save logichub/c1bfa144f4503d4515b6a01de49c8ce3 to your computer and use it in GitHub Desktop.
Save logichub/c1bfa144f4503d4515b6a01de49c8ce3 to your computer and use it in GitHub Desktop.

Revisions

  1. logichub revised this gist Feb 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vendor-orders.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?php

    /* See this {@link https://gist.github.com/logichub/047b0e785bedbc076a8374f95d60b044 link}
    /* See this link: https://gist.github.com/logichub/047b0e785bedbc076a8374f95d60b044
    * after creating this file in your child theme as mentioned below:
    */

  2. logichub revised this gist Feb 10, 2019. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion vendor-orders.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,11 @@
    <?php

    /* See this {@link https://gist.github.com/logichub/047b0e785bedbc076a8374f95d60b044 link}
    * after creating this file in your child theme as mentioned below:
    */

    /*
    * The template for displaying vendor pending shipping table dashboard widget
    * The template for displaying vendor orders
    * Override this template by copying it to yourtheme/dc-product-vendor/vendor-dashboard/vendor-orders.php
    *
    * @author WC Marketplace
  3. logichub created this gist Feb 10, 2019.
    89 changes: 89 additions & 0 deletions vendor-orders.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    <?php
    /*
    * The template for displaying vendor pending shipping table dashboard widget
    * Override this template by copying it to yourtheme/dc-product-vendor/vendor-dashboard/vendor-orders.php
    *
    * @author WC Marketplace
    * @package WCMp/Templates
    * @version 3.0.0
    */
    if (!defined('ABSPATH')) {
    // Exit if accessed directly
    exit;
    }
    global $WCMp;
    $product_sales_report_table_headers = apply_filters('wcmp_datatable_widget_product_sales_report_table_headers', array(
    'product' => array('label' => __( 'Product', 'dc-woocommerce-multi-vendor' )),
    // 'revenue' => array('label' => __( 'Revenue', 'dc-woocommerce-multi-vendor' )),
    'unique_purchase'=> array('label' => __( 'Unique Purchases', 'dc-woocommerce-multi-vendor' )),
    ), get_current_user_id());
    ?>
    <p>This page shows all your designs that have sold over the past year.</p>
    <table id="widget_product_sales_report" class="table table-striped product_sold_last_week table-bordered wcmp-widget-dt" width="100%">
    <thead>
    <tr>
    <?php
    if($product_sales_report_table_headers) :
    foreach ($product_sales_report_table_headers as $key => $header) { ?>
    <th class="<?php if(isset($header['class'])) echo $header['class']; ?>"><?php if(isset($header['label'])) echo $header['label']; ?></th>
    <?php }
    endif;
    ?>
    <!--th><?php _e('Product', 'dc-woocommerce-multi-vendor'); ?></th>
    <th><?php _e('Revenue', 'dc-woocommerce-multi-vendor'); ?></th>
    <th><?php _e('Unique Purchases', 'dc-woocommerce-multi-vendor'); ?></th-->
    </tr>
    </thead>
    <tbody>
    </tbody>
    </table>
    <script>
    jQuery(document).ready(function($) {
    var product_sales_report_wgt;
    var columns = [];
    <?php if($product_sales_report_table_headers) {
    foreach ($product_sales_report_table_headers as $key => $header) { ?>
    obj = {};
    obj['data'] = '<?php echo esc_js($key); ?>';
    obj['className'] = '<?php if(isset($header['class'])) echo esc_js($header['class']); ?>';
    columns.push(obj);
    <?php }
    } ?>
    product_sales_report_wgt = $('#widget_product_sales_report').DataTable({
    ordering : true,
    paging: true,
    info: true,
    searching : true,
    processing: true,
    serverSide: true,
    responsive: true,
    language: {
    "emptyTable": "<?php echo trim(__('Not enough data.','dc-woocommerce-multi-vendor')); ?>",
    "zeroRecords": "<?php echo trim(__('Not enough data.','dc-woocommerce-multi-vendor')); ?>",

    },
    ajax:{
    <?php
    /* Add 'lh-endpoint' => 'lh-vendor-orders' to the AJAX URL, so we can use it later
    * to change the '$days_range' value conditionally. It will change the ajax url from
    * /wp-admin/admin-ajax.php?action=wcmp_widget_vendor_product_sales_report to
    * /wp-admin/admin-ajax.php?action=wcmp_widget_vendor_product_sales_report&lh-endpoint=vendor-orders
    */
    $args = array(
    'action' => 'wcmp_widget_vendor_product_sales_report',
    'lh-endpoint' => 'lh-vendor-orders',
    );
    ?>
    //url : '<?php //echo add_query_arg( 'action', 'wcmp_widget_vendor_product_sales_report', $WCMp->ajax_url() ); ?>',
    url : '<?php echo add_query_arg( $args, $WCMp->ajax_url() ); ?>',
    type: "post",
    error: function(xhr, status, error) {
    $("#widget_product_sales_report tbody").append('<tr class="odd"><td valign="top" colspan="<?php if(is_array($product_sales_report_table_headers)) count($product_sales_report_table_headers); ?>" class="dataTables_empty" style="text-align:center;">'+error+' - <a href="javascript:window.location.reload();"><?php _e('Reload', 'dc-woocommerce-multi-vendor'); ?></a></td></tr>');
    $("#widget_product_sales_report").css("display","none");
    }
    },
    columns: columns
    });
    new $.fn.dataTable.FixedHeader( product_sales_report_wgt );
    });
    </script>