From f859e64a57c624ff2daa2b21355f65a49fd4807d Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 29 Aug 2026 03:09:12 +0000
Subject: [PATCH] =Some more tweaks. Mostly on the MenuBlock and adding the Meta.php to WooCommerce Products
---
inc/meta/Meta.php | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/inc/meta/Meta.php b/inc/meta/Meta.php
index 1d34549..d929089 100644
--- a/inc/meta/Meta.php
+++ b/inc/meta/Meta.php
@@ -149,7 +149,7 @@
'type' => 'text',
'label' => 'Short Description',
];
- $fields['post_id'] = [
+ $fields['ID'] = [
'type' => 'text',
'label' => 'ID',
];
@@ -178,6 +178,7 @@
$product = wc_get_product($id);
+
$fields['sku'] = [
'type' => 'text',
'label' => 'SKU',
@@ -257,6 +258,23 @@
$value = '';
if ($this->type === 'option') {
$value = get_option(BASE . $fieldName, $config['default'] ?? '');
+ } else if ($this->wpObject && $this->wpObject->post_type === 'product') {
+ if (property_exists($this->wpObject, $fieldName)) {
+ $value = $this->wpObject->$fieldName;
+ } else {
+ $product = wc_get_product($this->wpObject->ID);
+ $value = match ($fieldName) {
+ 'sku' => $product->get_sku(),
+ '_price' => $product->get_price(),
+ 'description'=> $product->get_short_description(),
+ 'sale' => $product->get_sale_price(),
+ 'img' => $product->get_image_id(),
+ '_stock' => $product->get_stock_quantity(),
+ '_stock_status' => $product->get_stock_status(),
+ default => '',
+ };
+ }
+
} else if (
($this->wpObject && property_exists($this->wpObject, $fieldName))
|| ($type === 'user' && $this->wpObject && property_exists($this->wpObject->data, $fieldName))) {
@@ -688,7 +706,7 @@
/**
* Get default value for a field type
*/
- protected function getDefaultValue(string $name): mixed
+ protected function getDefaultValue(string $name): string|int|bool|array
{
$config = $this->item->getFieldConfig($name);
$type = $config['type'] ?? 'text';
--
Gitblit v1.10.0