Skip to content

Instantly share code, notes, and snippets.

@logichub
Last active February 10, 2019 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save logichub/047b0e785bedbc076a8374f95d60b044 to your computer and use it in GitHub Desktop.
Save logichub/047b0e785bedbc076a8374f95d60b044 to your computer and use it in GitHub Desktop.
Conditionally change the default value of `$days_range` from 7 days to 60 or 365 days on the Vendor Dashboard in WC Marketplace plugin - Part 2
<?php // Mind the opening php tag!
/* First create a new file in your child theme as mentioned here:
* https://gist.github.com/logichub/c1bfa144f4503d4515b6a01de49c8ce3
* Then put this code in your child theme's 'functions.php' file.
*/
// Conditionally change the default value of `$days_range` from 7 days to 60 or 365 days
function lh_wcmp_vendor_custom_sales_report( $days_range ) {
// get the value of 'endpoint' from URL
$lh_orders_endpoint = isset( $_GET['lh-endpoint'] ) && !empty( $_GET['lh-endpoint'] ) ? $_GET['lh-endpoint'] : '';
// check if 'endpoint' value is 'vendor-orders' or not
if ( 'lh-vendor-orders' !== $lh_orders_endpoint ) {
$days_range = 60; // if 'lh-endpoint' is not 'lh-vendor-orders', then show last 2 months orders
} else {
$days_range = 365; // if 'lh-endpoint' is 'lh-vendor-orders', then show orders from 1 year
}
return $days_range;
}
add_filter( 'wcmp_widget_vendor_product_sales_report_days_range', 'lh_wcmp_vendor_custom_sales_report' );
@logichub
Copy link
Author

See part 1 here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment