Use wc_get_template() for the template files

This commit is contained in:
Jeremy Pry 2023-09-28 10:12:24 -04:00 committed by Justin Palmer
parent 0cb181bd9f
commit 7553579032
No known key found for this signature in database
GPG Key ID: ACAB7C35AA2577AF
2 changed files with 8 additions and 4 deletions

View File

@ -37,9 +37,13 @@ class CustomerHistory {
// Calculate the data needed for the template.
$order_count = wc_get_customer_order_count( $customer_id );
$total_spent = wc_get_customer_total_spent( $customer_id );
$average_spent = $order_count ? $total_spent / $order_count : 0;
// Include the template file.
include dirname( WC_PLUGIN_FILE ) . '/templates/order/customer-history.php';
$args = array(
'order_count' => $order_count,
'total_spent' => $total_spent,
'average_spent' => $order_count ? $total_spent / $order_count : 0,
);
wc_get_template( 'order/customer-history.php', $args );
}
}

View File

@ -40,6 +40,6 @@ class SourceAttribution {
return;
}
include dirname( WC_PLUGIN_FILE ) . '/templates/order/source-data-fields.php';
wc_get_template( 'order/source-data-fields.php', array( 'meta' => $meta ) );
}
}