Last active
February 10, 2019 00:32
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See part 1 here.