Jake Vanderwerf
2026-07-10 f94860aacd6200fb24c9e7431eb379a368cb392d
inc/integrations/Helcim.php
@@ -2,6 +2,7 @@
namespace JVBase\integrations;
use Exception;
use JVBase\meta\Meta;
use WP_Error;
use WP_Post;
use JVBase\ui\Checkout;
@@ -25,6 +26,7 @@
 */
class Helcim extends Integrations
{
   protected static string $syncCustomer = 'helcim_sync_customer';
   protected string $service_name = 'helcim';
   protected string|array $apiBase = 'https://api.helcim.com/v2';
@@ -711,9 +713,6 @@
         return $desc;
      }, 10, 2);
      // Register queue operation types with IntegrationExecutor
      $this->registerQueueTypes();
      // Register webhook endpoint (handled by parent)
      $this->registerWebhookEndpoint();
   }
@@ -760,38 +759,16 @@
   }
   protected function registerQueueTypes(): void
   protected function registerAdditionalQueueTypes(IntegrationExecutor $executor): void
   {
      $queue    = JVB()->queue();
      $executor = new IntegrationExecutor();
      $queue->registry()->register('helcim_sync_to', new TypeConfig(
         executor:  $executor,
         chunkKey:  'items',
         chunkSize: 10,
         maxRetries: 3
      ));
      $queue->registry()->register('helcim_sync_from', new TypeConfig(
         executor:  $executor,
         chunkKey:  'items',
         chunkSize: 10,
         maxRetries: 3
      ));
      $queue->registry()->register('helcim_delete_from', new TypeConfig(
         executor:  $executor,
         chunkKey:  'external_ids',
         chunkSize: 20,
         maxRetries: 2
      ));
      $queue->registry()->register('helcim_import', new TypeConfig(
      $queue->registry()->register(self::$import, new TypeConfig(
         executor:   $executor,
         maxRetries: 3
      ));
      $queue->registry()->register('helcim_sync_customer', new TypeConfig(
      $queue->registry()->register(self::$syncCustomer, new TypeConfig(
         executor:   $executor,
         maxRetries: 2
      ));
@@ -1028,22 +1005,34 @@
   protected function handleTheSavePost(int $postID, \WP_Post $post, bool $update, array $settings): void
   {
      $fields = $this->getSyncFields($postID, 'post', ['share_to_helcim', 'schedule_helcim']);
      if (empty($fields['share_to_helcim'])) {
         return;
      }
      // Uses IntegrationExecutor via TypeRegistry instead of FilteredExecutor
      $this->queueOperation('sync_to', [
      error_log('==== [Helcim]::handleTheSavePost ====');
      $this->queueOperation(self::$syncTo, [
         'items'   => [$postID],
         'user_id' => $this->userID,
         'user'      => user_can($post->post_author, 'manage_options') ? null : $post->post_author
      ], [
         'priority' => 'high',
         'delay'    => 30,
      ]);
      Meta::forPost($postID)->set('_'.$this->service_name.'_sync_status', 'queued');
   }
   /**
    * Handle post deletion
    */
   public function handleDeletePost(int $postID): void
   {
      $item_id = Meta::forPost($postID)->get("_{$this->service_name}_item_id");
      update_post_meta($postID, BASE . '_helcim_sync_status', 'queued');
      if (empty($item_id)) {
         return;
      }
      $this->queueOperation(self::$deleteFrom, [
         'external_ids' => [$item_id],
         'post_id'      => $postID,
      ], [
         'priority' => 'high',
      ]);
   }
   protected function handleImportFromHelcim(): array