From 2127b1bdd73ecd2423e443992da4b442f5a3c1a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 04 Feb 2026 21:19:25 +0000
Subject: [PATCH] =Major overhaul of MetaManager.php -> Meta.php and RestRouteManager.php -> Rest.php. Seems to work for JakeVan

---
 inc/integrations/Helcim.php |   54 ++++++++++++++++++++++++++++++++----------------------
 1 files changed, 32 insertions(+), 22 deletions(-)

diff --git a/inc/integrations/Helcim.php b/inc/integrations/Helcim.php
index 05cc87c..a70ac16 100644
--- a/inc/integrations/Helcim.php
+++ b/inc/integrations/Helcim.php
@@ -1,7 +1,7 @@
 <?php
 namespace JVBase\integrations;
 
-use JVBase\meta\MetaManager;
+use JVBase\meta\Meta;
 use Exception;
 use WP_Error;
 use WP_REST_Request;
@@ -157,6 +157,10 @@
 	 */
 	protected function registerAdditionalHooks(): void
 	{
+		$this->ensureInitialized();
+		if (!$this->isSetUp()) {
+			return;
+		}
 		// User login tracking for security
 		add_action('wp_login', [$this, 'trackUserLogin'], 10, 2);
 
@@ -240,9 +244,9 @@
 		}
 		?>
 		<button type="button" class="toggle-cart row" title="Your Cart" data-action="toggle-cart" aria-label="Open Cart" aria-controls="checkout" aria-expanded="false" hidden>
-			<?= jvbIcon('cart')?><span class="abs"></span><span class="abs count"></span>
+			<?= jvbIcon('shopping-cart')?><span class="abs"></span><span class="abs count"></span>
 		</button>
-		<aside id="cart">
+		<aside id="cart" class="main">
 			<form id="checkout" data-form-id="checkout" data-save="checkout">
 				<?php
 				$tabs = [
@@ -461,7 +465,7 @@
 					<label for="quantity"></label>
 					<div class="quantity field" data-min="0" data-max="50" data-step="1" data-price="" data-id="">
 						<button type="button" class="decrease" aria-label="Decrease quantity">
-							<?= jvbIcon('minus') ?>
+							<?= jvbIcon('minus-square') ?>
 						</button>
 						<input type="number" name="quantity" value="1" min="0" max="50">
 						<button type="button" class="increase" aria-label="Increase quantity">
@@ -527,6 +531,10 @@
 	 */
 	public function enqueueScripts(): void
 	{
+		$this->ensureInitialized();
+		if (!$this->isSetUp()) {
+			return;
+		}
 		// Helcim JS SDK
 		$sdk_url = $this->is_test_mode
 			? 'https://helcim-js-sandbox.helcim.com/v1/helcim.js'
@@ -658,7 +666,7 @@
 				$post = get_post($post_id);
 				if (!$post) continue;
 
-				$meta = new MetaManager($post_id, 'post');
+				$meta = Meta::forPost($post_id);
 				$field_map = $this->field_mappings[$post->post_type] ?? [];
 
 				// Prepare product data for Helcim
@@ -667,12 +675,12 @@
 					'description' => $post->post_content,
 					'productCode' => get_post_meta($post_id, BASE . '_helcim_product_code', true) ?: 'WP-' . $post_id,
 					'type' => $content_type,
-					'price' => floatval($meta->getValue('price')) * 100, // Convert to cents
-					'taxable' => (bool)$meta->getValue('is_taxable'),
+					'price' => floatval($meta->get('price')) * 100, // Convert to cents
+					'taxable' => (bool)$meta->get('is_taxable'),
 				];
 
 				// Handle variations
-				$variations = $meta->getValue('product_variations');
+				$variations = $meta->get('product_variations');
 				if (!empty($variations)) {
 					$product_data['variations'] = $this->prepareVariations($variations);
 				}
@@ -830,7 +838,7 @@
 
 		if ($post_id) {
 			// Update meta data
-			$meta = new MetaManager($post_id, 'post');
+			$meta = Meta::forPost($post_id);
 			$meta->setAll([
 				'price' => $product['price'] / 100, // Convert from cents
 				'_helcim_product_id' => $product['productId'],
@@ -881,11 +889,10 @@
 		// Send notification
 		$user = get_user_by('ID', $user_id);
 		if ($user) {
-			wp_mail(
+			JVB()->email()->sendEmail(
 				$user->user_email,
 				'Security: Password Reset Required',
 				'For your security, please reset your password to continue accessing your account and saved payment methods.',
-				['Content-Type: text/html; charset=UTF-8']
 			);
 		}
 	}
@@ -1137,23 +1144,26 @@
 	private function sendWelcomeEmail(\WP_User $user, string $reset_key): void
 	{
 		$site_name = get_bloginfo('name');
-		$reset_url = get_home_url(2, "wp-login.php?action=rp&key=$reset_key&login=" . rawurlencode($user->user_login), 'login');
+		$reset_url = get_home_url(null, "login?action=rp&key=$reset_key&login=" . rawurlencode($user->user_login), 'login');
 
 		$message = sprintf(
 			"Welcome to %s!\n\n" .
-			"Your account has been created. Please click the link below to set your password:\n\n" .
+			"Your account has been created. Please click the button below to set your password:\n\n" .
+			"%s\n\n" .
+			"Or, copy and paste the link below:\n\n".
 			"%s\n\n" .
 			"Once you've set your password, you can:\n" .
 			"- View your order history\n" .
 			"- Save your favorite items\n" .
 			"- Speed up checkout with saved payment methods\n\n" .
-			"Thanks,\n%s",
+			"If you didn't create this account, please ignore this email.\n\n" .
+			"Thanks,\n",
 			$site_name,
-			$reset_url,
-			$site_name
+			JVB()->email()->button('Reset Password', $reset_url),
+			JVB()->email()->link($reset_url),
 		);
 
-		jvbMail(
+		JVB()->email()->sendEmail(
 			$user->user_email,
 			sprintf('[%s] Welcome! Set Your Password', $site_name),
 			$message
@@ -1218,8 +1228,8 @@
 			$post_id = intval($item['id'] ?? 0);
 			if (!$post_id) continue;
 
-			$meta = new MetaManager($post_id, 'post');
-			$price = floatval($meta->getValue('price'));
+			$meta = Meta::forPost($post_id);
+			$price = floatval($meta->get('price'));
 			$quantity = intval($item['quantity'] ?? 1);
 
 			$total += ($price * $quantity * 100); // Convert to cents
@@ -1244,12 +1254,12 @@
 			if (!$post_id) continue;
 
 			$post = get_post($post_id);
-			$meta = new MetaManager($post_id, 'post');
+			$meta = Meta::forPost($post_id);
 
 			$line_items[] = [
 				'description' => $post->post_title,
 				'quantity' => intval($item['quantity'] ?? 1),
-				'price' => floatval($meta->getValue('price')) * 100,
+				'price' => floatval($meta->get('price')) * 100,
 				'productCode' => get_post_meta($post_id, BASE . '_helcim_product_code', true) ?: 'WP-' . $post_id
 			];
 		}
@@ -1481,7 +1491,7 @@
 			update_user_meta($user->ID, BASE . '_helcim_customer_updated', current_time('mysql'));
 
 			// Clear cached customer data
-			$this->cache->delete('helcim_customer_' . $user->ID);
+			$this->cache->forget('helcim_customer_' . $user->ID);
 		}
 
 		return true;

--
Gitblit v1.10.0