Compare commits

...

40 Commits

Author SHA1 Message Date
3wc
22063a6ba0 Customer name and address size tweaks
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-17 10:45:00 -04:00
3wc
8a17a922ac Allow overwriting during deployment
Some checks reported errors
continuous-integration/drone/push Build was killed
2024-07-16 18:39:31 -04:00
3wc
960d6a22f2 Fix path for Drone deployment
Some checks failed
continuous-integration/drone/push Build is failing
2024-07-16 18:36:13 -04:00
3wc
9e049f7fa6 Add live site Drone
Some checks failed
continuous-integration/drone/push Build is failing
2024-07-16 18:34:02 -04:00
3wc
2e30e12488 Working sync-from-live
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-16 18:27:36 -04:00
3wc
a9b655e04f Fix incorrect label generation
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-16 18:23:17 -04:00
3wc
5832b48479 Initialise is_organic to avoid warning 2024-07-10 19:48:04 -04:00
3wc
7890a955ce Add makefile rule to export theme ZIP
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-10 19:40:10 -04:00
3wc
986f7d8856 Bump version number for clarity
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-10 19:37:17 -04:00
52e97d16d8 whoopsie, extraneous code
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-10 19:32:49 -04:00
45c13bf515 test for existence of shipping address and use that, otherwise use billing address
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-10 19:31:36 -04:00
3wc
70886ea67d Further fix to array handling
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-09 14:30:08 -04:00
83be51bf32 dont print error
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-09 14:20:39 -04:00
3wc
6f3069bee9 Handle previous orders without coffees assigned
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-09 14:17:39 -04:00
cd14c04689 error handling
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-09 14:12:14 -04:00
3wc
dfdf13cf6f Initialise $is_new to prevent warning on live site
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-09 00:19:57 -04:00
3wc
39ba56eca6 Fix crash on renewal..
All checks were successful
continuous-integration/drone/push Build is passing
..again?
2024-07-08 23:52:39 -04:00
d6004d6cb3 they wanted customer name a bit bigger, was not legible on the print
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-07 12:55:08 -04:00
3wc
e7f5673a19 Fix coffee list rotation
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-05 19:01:24 -04:00
3wc
0852986599 Revert "testing renewal fix, issue 3270"
This reverts commit 7563c632f5.
2024-07-05 18:55:32 -04:00
3wc
b3f48f098c Wider area for "origin" to avoid line breaks 2024-07-05 18:50:15 -04:00
7563c632f5 testing renewal fix, issue 3270
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-04 22:25:42 -04:00
cc541c9e7f absolute spacing from the bottom for order details
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-04 19:17:11 -04:00
de601b4266 testing wrt 3268
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-04 15:58:29 -04:00
2bb5cf122c make long customer and coffee names fit on one line
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-04 19:16:05 +05:00
4ea9d5d69c remove redundant css 2024-07-04 18:56:48 +05:00
525e7c1463 Merge branch 'main' of ssh://git.autonomic.zone:2222/autonomic-cooperative/mont58-theme
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-04 18:47:21 +05:00
34d9cf604f remove unneccessary css link 2024-07-04 18:38:33 +05:00
3wc
58d67a4ec6 Limit "origin" width
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2024-07-01 11:54:39 -04:00
3wc
bbca48ef59 Fix label positioning for non-coffee items
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2024-07-01 11:36:27 -04:00
3wc
19cd99cea7 Tweak sizing
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-28 21:00:33 -04:00
e70171a798 re-center label order details
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-28 23:59:06 +05:00
cd564dc6fe fixed label font?
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-28 11:47:22 -04:00
0ed33f7321 fix order details font on label
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-28 20:26:30 +05:00
b43b5989eb add font file for label
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-28 19:29:24 +05:00
3wc
5df235a208 Tweak address positioning
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-27 11:43:47 -04:00
ad65b5a4b8 Merge branch 'main' of ssh://git.autonomic.zone:2222/autonomic-cooperative/mont58-theme
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-27 20:35:22 +05:00
83e8133d3b attempt #2: link acumin font to order label html 2024-06-27 20:34:33 +05:00
3wc
3ea3cf7e6f Positioning fixes for non-coffee items
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-27 11:29:47 -04:00
3wc
2046a23a4b Initial work on showing labels for non-coffee items 2024-06-27 11:29:47 -04:00
11 changed files with 222 additions and 90 deletions

View File

@ -2,7 +2,7 @@
kind: pipeline
name: deploy main branch to live site
steps:
- name: docker cp deploy
- name: copy theme files to staging
image: git.coopcloud.tech/coop-cloud/docker-cp-deploy:latest
settings:
host: smol-wp.autonomic.zone
@ -12,6 +12,19 @@ steps:
dest: /var/www/html/
deploy_key:
from_secret: drone_ssh_smol-wp.autonomic.zone
when:
branch:
- staging
- name: copy theme files to live
image: appleboy/drone-scp
settings:
host: web1.mont58coffee.com
username: autonomic
overwrite: true
key:
from_secret: drone_ssh_mont58coffee.com
target: /var/www/production.mont58coffee.com/web/
source: wp-content/themes/mont58-coffee/
when:
branch:
- main

View File

@ -2,6 +2,10 @@
# REQUIRED SETTINGS (you will need these) #
##############################################################################
# run `make fetch_db_info` to find these out
DB_USER=
DB_PASSWORD=
DB_NAME=
##############################################################################
# COMMON SETTINGS (you may need these) #
@ -37,5 +41,10 @@ PROJECT_NAME=mont58
# Site URL, also just needs to be set once per project
SITE_URL=mont58-staging.smol-wp.autonomic.zone
SSH_USER=autonomic
SSH_HOST=web1.mont58coffee.com
SSH_PATH=/var/www/production.mont58coffee.com/web/
SSH_PORT=22
# Multi-site config
#WORDPRESS_CONFIG_EXTRA="define('MULTISITE', true); define('SUBDOMAIN_INSTALL', true); define('DOMAIN_CURRENT_SITE', 'frms.localhost'); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1); define('SUNRISE', true);"

2
.gitignore vendored
View File

@ -3,7 +3,7 @@
/node_modules
/wp-content/**
!/wp-content/themes/mont58-coffee/**
/data/**
!/data/.gitkeep

14
.gitignore~ Normal file
View File

@ -0,0 +1,14 @@
/.env
/node_modules
/wp-content/**
!/wp-content/themes/mont58-coffee/**
/data/**
!/data/.gitkeep
.vscode/
**.tar.gz
**.sql
**.zip

View File

@ -22,12 +22,14 @@ services:
- WORDPRESS_DB_NAME=wordpress
- WORDPRESS_CONFIG_EXTRA=${WORDPRESS_CONFIG_EXTRA}
- WORDPRESS_DEBUG=${WORDPRESS_DEBUG}
- WORDPRESS_TABLE_PREFIX=kM7KXt7HQ_
- PHP_EXTENSIONS=calendar
- PAGER=more
container_name: "${PROJECT_NAME}_wordpress"
db:
image: "mariadb:10.6"
command: --innodb-buffer-pool-size=10G
volumes:
- "${MARIADB_VOLUME:-mariadb}:/var/lib/mysql"
networks:

View File

@ -8,6 +8,8 @@ if [ -n "$PHP_EXTENSIONS" ]; then
done
fi
echo 'memory_limit = 2048M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;
if ! id -u "user" >/dev/null ; then
useradd -u 1000 -m user
mkdir /var/www/html/vendor

View File

@ -109,14 +109,53 @@ uploads_load:
## Sync wp-content from site
uploads_pull: uploads_fetch uploads_load
fetch_db_info:
ssh -p$(SSH_PORT) $(SSH_USER)@$(SSH_HOST) grep DB $(SSH_PATH)/wp-config.php
## Download database from dev site
db_fetch:
$(ABRA) app run $(SITE_URL) db bash -c 'mariadb-dump -u root -p"$$(cat /run/secrets/db_root_password)" wordpress' | gzip > data/dbdump.sql.gz
ssh -p$(SSH_PORT) autonomic@web1.mont58coffee.com mysqldump -u $(DB_USER) -p$(DB_PASSWORD) "$(DB_NAME)" | gzip > data/dbdump.sql.gz
## Load latest database from ~/.abra/backups
db_load:
zcat data/dbdump.sql.gz | $(_DOCKER_COMPOSE) exec -T db mysql -u wordpress -pwordpress wordpress
db_pull: db_fetch db_load fix_url
define SQL_HEADER
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
endef
export SQL_HEADER
define SQL_FOOTER
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
endef
export SQL_FOOTER
db_convert:
gunzip data/database.sql.gz
sed -i -e 's/SERVMASK_PREFIX/wp/g' -e 's/,0x,/,0,/g' data/database.sql
echo "$$SQL_HEADER" | cat - data/database.sql > data/database_wrapped.sql
echo "$$SQL_FOOTER" >> data/database_wrapped.sql
mv data/database_wrapped.sql data/database.sql
## Replace site URL
fix_url:
$(_DOCKER_COMPOSE) exec -u user wordpress wp --url=https://$(SITE_URL) search-replace --all-tables-with-prefix 'https://$(SITE_URL)' 'http://$(PROJECT_NAME).localhost'
@ -125,18 +164,8 @@ fix_url:
set_local_password:
$(_DOCKER_COMPOSE) exec -u user wordpress wp user update $(USERNAME) --user_pass=password
db_pull: db_fetch db_load fix_url
## Download wp-content files from site
plugins_fetch:
$(ABRA) app run --no-tty $(SITE_URL) app tar --owner=0 --group=0 --no-same-owner --no-same-permissions -czf- /var/www/html/wp-content/plugins/ > data/plugins.tar.gz
## Load latest plugins from data/plugins.tar.gz
plugins_load:
tar -C wp-content --strip-components=4 -xzf data/plugins.tar.gz
## Sync plugins from site
plugins_pull: plugins_fetch plugins_load
plugins_pull:
rsync -Pavz -e 'ssh -p$(SSH_PORT)' $(SSH_USER)@$(SSH_HOST):$(SSH_PATH)/wp-content/plugins/ wp-content/plugins/
## Download parent theme from site
theme_fetch:
@ -149,6 +178,14 @@ theme_load:
## Sync wp-content from site
theme_pull: theme_fetch theme_load
#######################################
# Releases
#######################################
# Generate ZIP of theme
theme_export:
cd wp-content/themes/mont58-coffee/ && zip -r ../../../data/mont58-theme_2024-07-09.zip . && cd -
# "Arguments" for makefiles..
# https://stackoverflow.com/a/6273809/1826109
%:

View File

@ -152,27 +152,29 @@ function action_wcs_renewal_order_created($order, $subscription)
$order_coffees = [];
$seen_subscriptions = [];
// Get the latest coffee seen in each coffee list from the previous order
foreach (array_reverse($last_order_coffees) as $last_order_coffee) {
if (
array_key_exists(
$last_order_coffee["coffee_list"]->ID,
$seen_subscriptions
)
) {
continue;
if ($last_order_coffees) { // Check last_order_coffees isn't null or false
// Get the latest coffee seen in each coffee list from the previous order
foreach (array_reverse($last_order_coffees) as $last_order_coffee) {
if (
array_key_exists(
$last_order_coffee["coffee_list"]->ID,
$seen_subscriptions
)
) {
continue;
}
$position_in_list = array_search(
$last_order_coffee["coffee"]->ID,
$last_order_coffee["coffee_list"]->coffees
);
if ($position_in_list === false) {
// ignore this, can't find it in list anymore
continue;
}
$seen_subscriptions[
$last_order_coffee["coffee_list"]->ID
] = $position_in_list;
}
$position_in_list = array_search(
$last_order_coffee["coffee"]->ID,
$last_order_coffee["coffee_list"]->coffees
);
if (!$position_in_list) {
// ignore this, can't find it in list anymore
continue;
}
$seen_subscriptions[
$last_order_coffee["coffee_list"]->ID
] = $position_in_list;
}
// Process coffee items based on the coffees in the last order
@ -181,6 +183,8 @@ function action_wcs_renewal_order_created($order, $subscription)
// Update the custom field "coffees" with the processed coffee data for the current renewal order
update_field("coffees", $order_coffees, $order->get_ID());
}
return $order;
}
// Hook the above function to the 'wcs_renewal_order_created' action
add_action(
@ -197,7 +201,7 @@ function mont58_coffee_label_add_sidepanel()
{
add_meta_box(
"mont58_coffee_label_sidepanel",
"Coffee Label",
"Label",
"mont58_coffee_label_render_sidepanel",
"shop_order",
"side",
@ -246,13 +250,3 @@ add_filter(
10,
3
);
// import acumin variable font
function mont58coffee_enqueue_fonts()
{
wp_enqueue_style(
"mont58coffee-fonts",
get_theme_file_uri("/fonts/acumin-variable-concept.css")
);
}
add_action("wp_enqueue_scripts", "mont58coffee_enqueue_fonts");

View File

@ -2,6 +2,6 @@
Theme Name: Mont58 Coffee
Description: Theme for mont58coffee.com - child theme of Bridge
Template: bridge
Version: 1.0.0
Version: 1.1.0
Text Domain: mont58coffee
*/
*/

View File

@ -13,100 +13,144 @@ if(!is_user_logged_in()){
<title>Coffee Label</title>
<link rel="preconnect" href="https://api/fonts.coollabs.io">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@100..900&display=swap" rel="stylesheet">
<link href="<?php echo get_theme_file_uri('/fonts/acumin-variable-concept.css') ?>" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<style>
@page {
size: 7cm 7cm;
margin: 0;
}
/* acumin-variable-concept */
@font-face {
font-family: Acumin Variable Concept;
font-style: normal;
font-weight: 400;
src: local("Acumin Variable Concept"), local("AcuminVariableConcept"), url(<?php echo get_theme_file_uri('/fonts/acumin-variable-concept.woff2'); ?>) format("woff2");
}
body {
margin: 0;
}
.container {
display: flex;
flex-wrap: wrap;
}
.label {
width: calc(0.35* 400px);
height: calc(0.35 *400px);
width: 6.8cm;
height: 6.8cm;
border-radius: 50%;
padding: calc(0.35 * 2rem);
/* margin: calc(0.35 * 2rem); */
margin: 0.05cm;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
position: relative;
background: linear-gradient(
0deg,
rgba(255, 255, 255, 1) 28%,
rgba(231, 184, 32, 1) 28%
);
/* border: 1px solid black; */
}
.label .product-details {
font-family: 'Acumin Variable Concept', sans-serif;
font-size: calc(0.35 * 21px);
letter-spacing: calc(0.35 * 2px);
letter-spacing: 0.23mm;
text-transform: uppercase;
margin-top: 2.5em;
margin-bottom: 2em;
font-weight: 500;
margin-top: 0.6cm;
font-weight: bold;
font-variation-settings: 'wdth' 58, 'wght' 600;
font-size: 4mm;
}
.label .product-details p {
margin-block: 0.5em;
margin-block: 1.5mm;
}
.label .product-details .origin {
font-size: calc(0.35 * 28px);
font-size: 4mm; /* so that 20 char names fit on one line */
font-weight: 700;
letter-spacing: calc(0.35 * 4px);
margin-block: 1.2em 0.8em;
min-height: calc(0.35 * 33px);
letter-spacing: calc(0.4 * 4px);
margin-block: 3mm;
min-height: 3mm;
font-variation-settings: 'wdth' 70, 'wght' 600;
margin-inline: auto;
}
.label .product-details .origin.non-coffee {
margin-top: 2.3cm;
}
.label .product-details .weight {
text-transform: lowercase;
font-weight: bold;
font-family: sans-serif;
font-size: calc(0.35 * 18px);
font-size: 4mm;
}
.label .product-details .code {
min-height: calc(0.35 * 20px);
letter-spacing: calc(0.35 * 10px);
margin-top: 1.5em;
font-size: calc(0.35 * 16px);
min-height: 6mm;
letter-spacing: calc(0.4 * 10px);
margin-top: 2mm;
font-size: 4mm;
}
.label .order-details {
padding-bottom: 1em;
font-size: calc(0.35 * 17px);
text-align: center;
width: 100%;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 3.9mm; /* so that names as long as 50 characters stay on one line */
position: absolute;
bottom: 1.8mm; /* Adjust this value to set the distance from the bottom of the label */
left: 0;
right: 0;
}
.label .order-details p {
margin-block: 0.4em;
margin-block: 0.5mm;
}
</style>
</head>
<body>
<div class="container">
<?php
$j = 0;
foreach ($_GET["order_ids"] as $order_id) {
$order = wc_get_order($order_id);
$first_name = $order->get_billing_first_name();
$last_name = $order->get_billing_last_name();
$postcode = $order->get_billing_postcode();
// Check if shipping details exist
$shipping_first_name = $order->get_shipping_first_name();
$shipping_last_name = $order->get_shipping_last_name();
$shipping_postcode = $order->get_shipping_postcode();
// If any shipping detail is empty, use billing details
if (empty($shipping_first_name) || empty($shipping_last_name) || empty($shipping_postcode)) {
$first_name = $order->get_billing_first_name();
$last_name = $order->get_billing_last_name();
$postcode = $order->get_billing_postcode();
} else {
$first_name = $shipping_first_name;
$last_name = $shipping_last_name;
$postcode = $shipping_postcode;
}
$items = $order->get_items();
$total_items = $order->get_item_count();
$roast_date = (new DateTime())->modify("-3 days")->format("d/m/Y");
$gift_message = $order->get_meta("_shipping_gift_message");
$order_subscription_coffees = get_field("coffees", $order_id);
$is_new = false;
foreach ($items as $item) {
$j = 0;
// checking if product is a coffee
$product_id = $item->get_product_id();
$product_categories = get_the_terms($product_id, "product_cat");
$is_coffee = false;
$is_subscription = false;
$is_organic = false;
if (
!empty($product_categories) &&
@ -122,14 +166,17 @@ if(!is_user_logged_in()){
}
}
}
$product_name = '';
$roast = '';
if (!$is_coffee && !$is_subscription) {
continue;
if ($is_coffee || $is_subscription) {
$brew_method = $item->get_meta("pa_brew-method");
$weight = $item->get_meta("weight");
} else {
$product_name = $item->get_name();
}
$brew_method = $item->get_meta("pa_brew-method");
$weight = $item->get_meta("weight");
if ($is_coffee) {
// Non-subscription order
$product_name = $item->get_name();
@ -152,19 +199,27 @@ if(!is_user_logged_in()){
$quantity = $item->get_quantity();
for ($i = 0; $i < $quantity; $i++) {
if ($is_subscription) {
$coffee = $order_subscription_coffees[$i + $j]["coffee"];
$product_name = $coffee->post_title;
$roast = get_field("roast_level", $coffee->ID);
$is_organic = get_field("is_organic", $coffee->ID);
} ?>
if (($order_subscription_coffees !== null)
&& (is_object($order_subscription_coffees[$i + $j]["coffee"]))){
$coffee = $order_subscription_coffees[$i + $j]["coffee"];
$product_name = $coffee->post_title;
$roast = get_field("roast_level", $coffee->ID);
$is_organic = get_field("is_organic", $coffee->ID);
}
} ?>
<div class="label">
<div>
<div class="product-details">
<?php if ($is_coffee || $is_subscription) { ?>
<p class="weight"><?php echo $weight; ?></p>
<p class="origin"><?php echo $product_name; ?></p>
<?php } ?>
<p class="origin<?php echo ($is_coffee || $is_subscription) ? "" : " non-coffee"; ?>"><?php echo $product_name; ?></p>
<?php if ($is_coffee || $is_subscription) { ?>
<p class="bean-type"><?php echo $brew_method; ?></p>
<p class="roast"><?php echo $roast; ?> Roast</p>
<p class="date">Roasted on: <span><?php echo $roast_date; ?></span></p>
<?php } ?>
<p class="code"><?php
echo $is_new ? "N" : "";
echo $gift_message ? "G" : "";
@ -172,7 +227,13 @@ if(!is_user_logged_in()){
?></p>
</div>
<div class="order-details">
<p class="customer-name"><?php echo "$first_name $last_name"; ?></p>
<?php
$customer_name = "$first_name $last_name";
if (strlen($customer_name) > 26) {
$customer_name = substr($customer_name, 0, 25) . '…';
}
?>
<p class="customer-name"><?php echo $customer_name; ?></p>
<p class="purchase-code"><?php echo $postcode; ?></p>
<p class="quantity"><?php echo $total_items; ?></p>
</div>