Compare commits
6 Commits
577703eead
...
master
Author | SHA1 | Date | |
---|---|---|---|
841098af7a | |||
7d322af818 | |||
aa85dc5afc | |||
1eb14bffb3 | |||
7ca53e11d4 | |||
0d8bac003b |
@ -27,7 +27,7 @@ function mont58_coffee_label_add_sidepanel() {
|
|||||||
function mont58_coffee_label_render_sidepanel($post) {
|
function mont58_coffee_label_render_sidepanel($post) {
|
||||||
// Render the content of the sidepanel here
|
// Render the content of the sidepanel here
|
||||||
$order_id = $post->ID;
|
$order_id = $post->ID;
|
||||||
echo '<a href="/coffee-label?order_id=' . $order_id . '" class="button button-primary">View Label</a>';
|
echo '<a href="/coffee-label?order_id=' . $order_id . '" class="button button-primary" target="_blank">View Label</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load custom template
|
// Load custom template
|
||||||
|
@ -7,6 +7,7 @@ $last_name = $order->get_billing_last_name();
|
|||||||
$postcode = $order->get_billing_postcode();
|
$postcode = $order->get_billing_postcode();
|
||||||
$items = $order->get_items();
|
$items = $order->get_items();
|
||||||
$order_date = $order->get_date_created()->date('d/m/Y');
|
$order_date = $order->get_date_created()->date('d/m/Y');
|
||||||
|
$gift_message = $order->get_meta('_shipping_gift_message');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ $order_date = $order->get_date_created()->date('d/m/Y');
|
|||||||
<style>
|
<style>
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
@ -29,7 +31,7 @@ $order_date = $order->get_date_created()->date('d/m/Y');
|
|||||||
height: 400px;
|
height: 400px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
margin-inline: 2rem;
|
margin: 2rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -89,12 +91,27 @@ $order_date = $order->get_date_created()->date('d/m/Y');
|
|||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<?php foreach ($items as $item) {
|
<?php foreach ($items as $item) {
|
||||||
|
// checking if product is a coffee
|
||||||
|
$product_id = $item->get_product_id();
|
||||||
|
$product_categories = get_the_terms($product_id, 'product_cat');
|
||||||
|
$is_coffee = false;
|
||||||
|
|
||||||
|
if (!empty($product_categories) && !is_wp_error($product_categories)) {
|
||||||
|
foreach ($product_categories as $product_category) {
|
||||||
|
if ($product_category->slug == 'coffee') {
|
||||||
|
$is_coffee = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($is_coffee) {
|
||||||
$quantity = $item->get_quantity();
|
$quantity = $item->get_quantity();
|
||||||
$product_name = $item->get_name();
|
$product_name = $item->get_name();
|
||||||
$brew_method = $item->get_meta('pa_brew-method');
|
$brew_method = $item->get_meta('pa_brew-method');
|
||||||
$weight = $item->get_meta('weight');
|
$weight = $item->get_meta('weight');
|
||||||
$product_id = $item->get_product_id();
|
|
||||||
$roast = get_field('roast_level', $product_id);
|
$roast = get_field('roast_level', $product_id);
|
||||||
|
$is_organic = get_field('is_organic', $product_id);
|
||||||
|
|
||||||
for ($i = 0; $i < $quantity; $i++) { ?>
|
for ($i = 0; $i < $quantity; $i++) { ?>
|
||||||
<div class="label">
|
<div class="label">
|
||||||
@ -105,7 +122,7 @@ $order_date = $order->get_date_created()->date('d/m/Y');
|
|||||||
<p class="bean-type"><?php echo $brew_method; ?></p>
|
<p class="bean-type"><?php echo $brew_method; ?></p>
|
||||||
<p class="roast"><?php echo $roast; ?> Roast</p>
|
<p class="roast"><?php echo $roast; ?> Roast</p>
|
||||||
<p class="date">Roasted on: <span><?php echo $order_date; ?></span></p>
|
<p class="date">Roasted on: <span><?php echo $order_date; ?></span></p>
|
||||||
<p class="code">NGO</p>
|
<p class="code">N<?php echo $gift_message ? 'G' : '' ?><?php echo $is_organic ? 'O' : '' ?></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="order-details">
|
<div class="order-details">
|
||||||
<p class="customer-name"><?php echo "$first_name $last_name"; ?></p>
|
<p class="customer-name"><?php echo "$first_name $last_name"; ?></p>
|
||||||
@ -115,6 +132,7 @@ $order_date = $order->get_date_created()->date('d/m/Y');
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php }
|
<?php }
|
||||||
|
}
|
||||||
} ?>
|
} ?>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
Reference in New Issue
Block a user