Jake Vanderwerf
2026-08-28 5b50afdcafd150186ea5c7b0e1cad98065590b35
inc/integrations/services/HelcimOld.php
@@ -1,11 +1,17 @@
<?php
namespace JVBase\integrations\services;
use Exception;
use JVBase\integrations\Integrations;
use JVBase\managers\queue\executors\IntegrationExecutor;
use JVBase\managers\queue\Queue;
use JVBase\managers\queue\TypeConfig;
use JVBase\meta\Meta;
use JVBase\ui\Checkout;
use WP_Error;
use WP_Post;
use WP_REST_Request;
use WP_REST_Response;
if (!defined('ABSPATH')) {
   exit;
@@ -757,7 +763,7 @@
   protected function registerAdditionalQueueTypes(IntegrationExecutor $executor): void
   {
      $queue    = JVB()->queue();
      $queue    = Queue::getInstance();
      $queue->registry()->register(self::$import, new TypeConfig(
         executor:   $executor,
@@ -999,7 +1005,7 @@
    * PRODUCT SYNC
    *****************************************************************/
   protected function handleTheSavePost(int $postID, \WP_Post $post, bool $update, array $settings): void
   protected function handleTheSavePost(int $postID, WP_Post $post, bool $update, array $settings): void
   {
      error_log('==== [Helcim]::handleTheSavePost ====');
@@ -1265,7 +1271,7 @@
   /**
    * Override the webhook request handler to capture raw body for signature verification
    */
   public function handleWebhookRequest(\WP_REST_Request $request): \WP_REST_Response
   public function handleWebhookRequest(WP_REST_Request $request): WP_REST_Response
   {
      $payload = $request->get_params();
      $payload['_headers']  = $request->get_headers();
@@ -1273,7 +1279,7 @@
      $success = $this->handleWebhook($payload);
      return new \WP_REST_Response([
      return new WP_REST_Response([
         'success' => $success,
      ], $success ? 200 : 400);
   }
@@ -1284,11 +1290,11 @@
    * Sync a WordPress post to Helcim as a product.
    * Called by IntegrationExecutor::processSyncTo()
    */
   public function syncPostToService(int $postID): array|\WP_Error
   public function syncPostToService(int $postID): array|WP_Error
   {
      $post = get_post($postID);
      if (!$post) {
         return new \WP_Error('not_found', "Post {$postID} not found");
         return new WP_Error('not_found', "Post {$postID} not found");
      }
      $helcimProductId = get_post_meta($postID, BASE . '_helcim_item_id', true);
@@ -1324,7 +1330,7 @@
    * Delete a product from Helcim.
    * Called by IntegrationExecutor::processDeleteFrom()
    */
   public function deleteFromService(string $externalId): array|\WP_Error
   public function deleteFromService(string $externalId): array|WP_Error
   {
      $response = $this->deleteRequest("products/{$externalId}");
@@ -1338,14 +1344,14 @@
   /**
    * Build Helcim product payload from a WordPress post.
    */
   protected function buildProductPayload(int $postID): array|\WP_Error
   protected function buildProductPayload(int $postID): array|WP_Error
   {
      $meta = \JVBase\meta\Meta::forPost($postID);
      $meta = Meta::forPost($postID);
      $post = get_post($postID);
      $price = $meta->get('price');
      if (empty($price) || !is_numeric($price)) {
         return new \WP_Error('invalid_price', "Post {$postID} has no valid price");
         return new WP_Error('invalid_price', "Post {$postID} has no valid price");
      }
      return [