My Workouts

[insert_php]
date_default_timezone_set(‘Australia/Sydney’);
global $current_user;
$putin = false;
$user_roles = $current_user->roles;

$finalhtml = “”;
$imgsrc = “”;
foreach ($user_roles as $ur){
$workoutneeded = “”;
$titleWO = “”;
switch (trim($ur)) {
case “coaching”:
$workoutneeded = “coaching”;
$titleWO = “Custom Coaching”;
break;
case “move_it_body_blitz”:
$workoutneeded = “move-it-body-blitz-workout”;
$titleWO = “Move It – Body Blitz”;
break;
case “move_it_elite”:
$workoutneeded = “move-it-elite”;
$titleWO = “Move It – Elite”;
break;
case “learn_to_run”:
//CHECK IF LEARN TO RUN IS ABLE TO BE SHOWN
//Get all orders made by the current user in the last 365 days
$customer_orders = get_posts( apply_filters( ‘woocommerce_my_account_my_orders_query’, array(
‘numberposts’ => $order_count,
‘meta_key’ => ‘_customer_user’,
‘meta_value’ => get_current_user_id(),
‘post_type’ => wc_get_order_types( ‘view-orders’ ),
‘post_status’ => array(‘wc-completed’, ‘wc-processing’),
)));

//Loop trough the orders
foreach ( $customer_orders as $customer_order ) {
$order = wc_get_order();
$orderMain = new WC_Order($customer_order->ID);
$items = $orderMain->get_items();

//Loop trough the order items and see if it is a product we need to cehck
foreach($items as $item) {
if (strpos($item[‘name’], ‘Learn’) !== false) {
$productid = $item[‘product_id’];
$releaseDate = get_post_meta($productid, ‘release_date’, true);
$expiryDate = get_post_meta($productid, ‘expiry_date’, true);
$releasetimestamp = strtotime($releaseDate);
$daterelease = date(‘d-m-Y’,$releasetimestamp);
$expirytimestamp = strtotime($expiryDate);
$dateexpiry = date(‘d-m-Y’,$expirytimestamp);
$todayDate = strtotime(date(‘d-m-Y’));
if($todayDate <= $expirytimestamp){ if($releasetimestamp <= $todayDate){ $putin = true; $imgsrc = "http://asit-group.com/running/wp-content/uploads/2016/03/ltr.jpg"; $workoutneeded = "learn-to-run"; $titleWO = "Learn To Run"; } } } } } break; case "farandfast": $workoutneeded = "far-and-fast"; $titleWO = "Far and Fast"; break; case "runclub": $date = new DateTime(); $week = $date->format(“W”);
if($week > 26){
$week = $week-26;
}
$counter = 0;
//while($counter < 5){ $workoutWanted = "/all-workout-list/run-club-workout-".($week + $counter); $finalhtml .= "

“;

$finalhtml .= ““;

$finalhtml .= “

Run Club Weekly Workout “.$week.”

“;
$finalhtml .= “

“;

$counter++;
//}
break;
}
if($titleWO != “”){
$redirecturl = “/all-workout-list/”.$workoutneeded;

$finalhtml .= “

“;
if($imgsrc != “”){
$finalhtml .= ““;
}

$finalhtml .= “

“.$titleWO.”

“;
$finalhtml .= “

“;
}

}

if ($finalhtml != “”){
$finalhtml .= “

“;
echo $finalhtml;
}
else{
echo (“

Sorry! It doesn’t look like there are any workouts here for you right now.

Please try again later, or, if you think this is an error, please contact us.

“);
}[/insert_php]

Leave A Reply:

(optional field)

No comments yet.