Compare commits

..

1 Commits

Author SHA1 Message Date
3wc
42e7f13b84 Initial work on showing labels for non-coffee items
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-10 20:56:15 -05:00
11 changed files with 74 additions and 208 deletions

View File

@ -2,7 +2,7 @@
kind: pipeline
name: deploy main branch to live site
steps:
- name: copy theme files to staging
- name: docker cp deploy
image: git.coopcloud.tech/coop-cloud/docker-cp-deploy:latest
settings:
host: smol-wp.autonomic.zone
@ -12,19 +12,6 @@ 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,10 +2,6 @@
# 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) #
@ -41,10 +37,5 @@ 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

View File

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

View File

@ -22,14 +22,12 @@ 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,8 +8,6 @@ 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,53 +109,14 @@ 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:
ssh -p$(SSH_PORT) autonomic@web1.mont58coffee.com mysqldump -u $(DB_USER) -p$(DB_PASSWORD) "$(DB_NAME)" | gzip > data/dbdump.sql.gz
$(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
## 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'
@ -164,8 +125,18 @@ fix_url:
set_local_password:
$(_DOCKER_COMPOSE) exec -u user wordpress wp user update $(USERNAME) --user_pass=password
plugins_pull:
rsync -Pavz -e 'ssh -p$(SSH_PORT)' $(SSH_USER)@$(SSH_HOST):$(SSH_PATH)/wp-content/plugins/ wp-content/plugins/
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
## Download parent theme from site
theme_fetch:
@ -178,14 +149,6 @@ 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,29 +152,27 @@ function action_wcs_renewal_order_created($order, $subscription)
$order_coffees = [];
$seen_subscriptions = [];
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;
// 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) {
// 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
@ -183,8 +181,6 @@ 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(
@ -201,7 +197,7 @@ function mont58_coffee_label_add_sidepanel()
{
add_meta_box(
"mont58_coffee_label_sidepanel",
"Label",
"Coffee Label",
"mont58_coffee_label_render_sidepanel",
"shop_order",
"side",

View File

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

View File

@ -15,143 +15,97 @@ if(!is_user_logged_in()){
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@100..900&display=swap" 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: 6.8cm;
height: 6.8cm;
width: calc(0.35* 400px);
height: calc(0.35 *400px);
border-radius: 50%;
margin: 0.05cm;
padding: calc(0.35 * 2rem);
/* margin: calc(0.35 * 2rem); */
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;
letter-spacing: 0.23mm;
font-family: 'Roboto Condensed';
font-size: calc(0.35 * 21px);
letter-spacing: calc(0.35 * 2px);
text-transform: uppercase;
margin-top: 0.6cm;
font-weight: bold;
font-variation-settings: 'wdth' 58, 'wght' 600;
font-size: 4mm;
margin-top: 2.5em;
margin-bottom: 2em;
font-weight: 500;
}
.label .product-details p {
margin-block: 1.5mm;
margin-block: 0.5em;
}
.label .product-details .origin {
font-size: 4mm; /* so that 20 char names fit on one line */
font-size: calc(0.35 * 28px);
font-weight: 700;
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;
letter-spacing: calc(0.35 * 4px);
margin-block: 1.2em 0.8em;
min-height: calc(0.35 * 33px);
}
.label .product-details .weight {
text-transform: lowercase;
font-weight: bold;
font-size: 4mm;
font-family: sans-serif;
font-size: calc(0.35 * 18px);
}
.label .product-details .code {
min-height: 6mm;
letter-spacing: calc(0.4 * 10px);
margin-top: 2mm;
font-size: 4mm;
min-height: calc(0.35 * 20px);
letter-spacing: calc(0.35 * 10px);
margin-top: 1.5em;
font-size: calc(0.35 * 16px);
}
.label .order-details {
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: 2.9mm; /* so that names as long as 50 characters stay on one line */
margin-top: 4.6mm; /* to center text inside white area */
position: absolute;
bottom: 5.9mm; /* Adjust this value to set the distance from the bottom of the label */
left: 0;
right: 0;
padding-bottom: 1em;
font-size: calc(0.35 * 17px);
}
.label .order-details p {
margin-block: 0.5mm;
margin-block: 0.4em;
}
</style>
</head>
<body>
<div class="container">
<?php
$j = 0;
foreach ($_GET["order_ids"] as $order_id) {
$order = wc_get_order($order_id);
// 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;
}
$first_name = $order->get_billing_first_name();
$last_name = $order->get_billing_last_name();
$postcode = $order->get_billing_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) &&
@ -167,9 +121,6 @@ if(!is_user_logged_in()){
}
}
}
$product_name = '';
$roast = '';
if ($is_coffee || $is_subscription) {
$brew_method = $item->get_meta("pa_brew-method");
@ -200,22 +151,18 @@ if(!is_user_logged_in()){
$quantity = $item->get_quantity();
for ($i = 0; $i < $quantity; $i++) {
if ($is_subscription) {
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);
}
} ?>
$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>
<?php } ?>
<p class="origin<?php echo ($is_coffee || $is_subscription) ? "" : " non-coffee"; ?>"><?php echo $product_name; ?></p>
<p class="origin"><?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>