__('Publish', 'fluent-cart'), self::PRODUCT_DRAFT => __('Draft', 'fluent-cart'), self::PRODUCT_PRIVATE => __('Private', 'fluent-cart'), self::PRODUCT_FUTURE => __('Scheduled', 'fluent-cart'), self::PRODUCT_TRASH => __('Trashed', 'fluent-cart'), ], []); if ($withLabel) { return $statues; } return array_keys($statues); } public static function getScheduleStatus($status): string { $statuses = [ 'pending' => Status::SCHEDULE_PENDING, 'processing' => Status::SCHEDULE_PROCESSING, 'completed' => Status::SCHEDULE_COMPLETED, 'failed' => Status::SCHEDULE_FAILED, ]; return $statuses[$status] ?? Status::SCHEDULE_PENDING; } public static function getLicenseStatus($status): string { $statuses = [ 'active' => Status::LICENSE_ACTIVE, 'disabled' => Status::LICENSE_DISABLED, 'expired' => Status::LICENSE_EXPIRED, ]; return $statuses[$status] ?? Status::LICENSE_ACTIVE; } public static function productAdminAllStatuses() { $statuses = self::getProductStatuses(); unset($statuses[self::PRODUCT_TRASH]); return array_keys($statuses); } // Order statuses public static function getOrderStatuses() { return apply_filters('fluent_cart/order_statuses', [ self::ORDER_PROCESSING => __('Processing', 'fluent-cart'), self::ORDER_COMPLETED => __('Completed', 'fluent-cart'), self::ORDER_ON_HOLD => __('On Hold', 'fluent-cart'), self::ORDER_CANCELED => __('Canceled', 'fluent-cart'), self::ORDER_FAILED => __('Failed', 'fluent-cart'), ], []); } public static function getEditableOrderStatuses() { $statuses = [ self::ORDER_ON_HOLD => __('On Hold', 'fluent-cart'), self::ORDER_PROCESSING => __('Processing', 'fluent-cart'), self::ORDER_COMPLETED => __('Completed', 'fluent-cart'), // 'archived' => __('Archived', 'fluent-cart'), self::ORDER_CANCELED => __('Canceled', 'fluent-cart') ]; return apply_filters('fluent_cart/editable_order_statuses', $statuses, []); } // Payment statuses public static function getPaymentStatuses() { return apply_filters('fluent_cart/payment_statuses', [ self::PAYMENT_PENDING => __('Pending', 'fluent-cart'), self::PAYMENT_PAID => __('Paid', 'fluent-cart'), self::PAYMENT_PARTIALLY_PAID => __('Partially Paid', 'fluent-cart'), self::PAYMENT_FAILED => __('Failed', 'fluent-cart'), self::PAYMENT_REFUNDED => __('Refunded', 'fluent-cart'), self::PAYMENT_PARTIALLY_REFUNDED => __('Partially Refunded', 'fluent-cart'), self::PAYMENT_AUTHORIZED => __('Authorized', 'fluent-cart'), self::PAYMENT_SCHEDULED => __('Payment Scheduled', 'fluent-cart'), ], []); } // Transaction statuses public static function getTransactionStatuses($withLabel = true) { return apply_filters('fluent_cart/transaction_statuses', [ self::TRANSACTION_PENDING => __('Pending', 'fluent-cart'), self::TRANSACTION_SUCCEEDED => __('Succeeded', 'fluent-cart'), self::TRANSACTION_AUTHORIZED => __('Authorized', 'fluent-cart'), self::TRANSACTION_FAILED => __('Failed', 'fluent-cart'), self::TRANSACTION_REFUNDED => __('Refunded', 'fluent-cart'), ], []); if ($withLabel) { return $statuses; } return array_keys($statuses); } public static function getEditableTransactionStatuses($withLabel = true) { $statuses = [ self::TRANSACTION_PENDING => __('Pending', 'fluent-cart'), self::TRANSACTION_SUCCEEDED => __('Succeeded', 'fluent-cart'), self::TRANSACTION_AUTHORIZED => __('Authorized', 'fluent-cart'), self::TRANSACTION_FAILED => __('Failed', 'fluent-cart'), self::TRANSACTION_REFUNDED => __('Refunded', 'fluent-cart'), ]; $statuses = apply_filters('fluent_cart/editable_transaction_statuses', $statuses, []); if ($withLabel) { return $statuses; } return array_keys($statuses); } // Shipping statuses public static function getShippingStatuses() { return apply_filters('fluent_cart/shipping_statuses', [ self::SHIPPING_UNSHIPPED => __('Unshipped', 'fluent-cart'), self::SHIPPING_SHIPPED => __('Shipped', 'fluent-cart'), self::SHIPPING_DELIVERED => __('Delivered', 'fluent-cart'), self::SHIPPING_UNSHIPPABLE => __('Unshippable', 'fluent-cart'), ], []); } public static function getEditableShippingStatuses() { $statuses = [ self::SHIPPING_UNSHIPPED => __('Unshipped', 'fluent-cart'), self::SHIPPING_SHIPPED => __('Shipped', 'fluent-cart'), self::SHIPPING_DELIVERED => __('Delivered', 'fluent-cart'), self::SHIPPING_UNSHIPPABLE => __('Unshippable', 'fluent-cart'), ]; return apply_filters('fluent_cart/editable_shipping_statuses', $statuses, []); } // Subscription statuses public static function getSubscriptionStatuses() { return apply_filters('fluent_cart/subscription_statuses', [ self::SUBSCRIPTION_PENDING => __('Pending', 'fluent-cart'), self::SUBSCRIPTION_ACTIVE => __('Active', 'fluent-cart'), self::SUBSCRIPTION_FAILING => __('Failing', 'fluent-cart'), self::SUBSCRIPTION_PAUSED => __('Paused', 'fluent-cart'), self::SUBSCRIPTION_EXPIRED => __('Expired', 'fluent-cart'), self::SUBSCRIPTION_EXPIRING => __('Expiring', 'fluent-cart'), self::SUBSCRIPTION_CANCELED => __('Canceled', 'fluent-cart'), self::SUBSCRIPTION_TRIALING => __('Trialing', 'fluent-cart'), self::SUBSCRIPTION_INTENDED => __('Intended', 'fluent-cart'), self::SUBSCRIPTION_PAST_DUE => __('Past Due', 'fluent-cart'), self::SUBSCRIPTION_COMPLETED => __('Completed', 'fluent-cart'), ], []); } // Get Validable Subscription Statuses public static function getValidableSubscriptionStatuses() { return apply_filters('fluent_cart/validable_subscription_statuses', [ self::SUBSCRIPTION_ACTIVE, self::SUBSCRIPTION_TRIALING, ], []); } // Stock statuses public static function getStockStatuses($withLabel = true) { $statues = [ self::STOCK_INSTOCK => __('In Stock', 'fluent-cart'), self::STOCK_OUTOFSTOCK => __('Out Of Stock', 'fluent-cart'), ]; if ($withLabel) { return $statues; } return array_keys($statues); } public static function getOrderSuccessStatuses() { return [ self::ORDER_COMPLETED, self::ORDER_PROCESSING, ]; } public static function getOrderFailedStatuses() { return [ self::ORDER_FAILED, //'refunded', self::ORDER_CANCELED, ]; } public static function getOrderPaymentSuccessStatuses() { return [ self::PAYMENT_PAID, self::PAYMENT_PARTIALLY_REFUNDED, self::PAYMENT_PARTIALLY_PAID, ]; } public static function getPaymentRetryableStatuses() { return [ self::PAYMENT_PENDING, self::PAYMENT_FAILED ]; } public static function getReportStatuses() { return [ self::PAYMENT_PAID, self::PAYMENT_REFUNDED, self::PAYMENT_PARTIALLY_PAID, self::PAYMENT_PARTIALLY_REFUNDED, ]; } public static function getTransactionSuccessStatuses() { return apply_filters('fluent_cart/transaction_success_statuses', [self::TRANSACTION_SUCCEEDED, self::TRANSACTION_AUTHORIZED], []); } // Get all statuses (optional utility) public static function all() { return [ 'product' => self::getProductStatuses(), 'order' => self::getOrderStatuses(), 'payment' => self::getPaymentStatuses(), 'transaction' => self::getTransactionStatuses(), 'shipping' => self::getShippingStatuses(), 'customer' => self::getEditableCustomerStatuses(), 'subscription' => self::getSubscriptionStatuses(), ]; } public static function getEditableCustomerStatuses() { $statuses = [ self::CUSTOMER_ACTIVE => __('Active', 'fluent-cart'), self::CUSTOMER_INACTIVE => __('Inactive', 'fluent-cart'), ]; return apply_filters('fluent_cart/editable_customer_statuses', $statuses, []); } // call when syncing status from external services, ex: public static function syncPaymentStatus($status) { $status = strtolower($status); $statuses = self::getPaymentStatuses(); if (isset($statuses[$status])) { return $status; } if ('completed' === $status) { return self::PAYMENT_PAID; } if ('succeeded' === $status) { return self::PAYMENT_PAID; } return $status; } public static function syncTransactionStatus($status) { $status = strtolower($status); $statuses = self::getTransactionStatuses(); if (isset($statuses[$status])) { return $status; } if ('paid' === $status) { return self::TRANSACTION_SUCCEEDED; } else if ('succeeded' === $status) { return self::TRANSACTION_SUCCEEDED; } return $status; } public static function syncSubscriptionStatus($status) { if ('cancelled' === $status || 'canceled' === $status) { return self::SUBSCRIPTION_CANCELED; } return $status; } public static function eventTriggers(): array { return [ 'require_list' => false, 'required' => true, 'key' => 'event_trigger', 'options' => [ 'order' => [ 'label' => __('Orders', 'fluent-cart'), 'options' => [ [ 'value' => 'order_paid_done', 'label' => __('Order Paid (Payment / Subscription)', 'fluent-cart') ], [ 'value' => 'order_status_changed_to_canceled', 'label' => __('Order Canceled', 'fluent-cart') ], [ 'value' => 'order_fully_refunded', 'label' => __('Order Refunded (Full)', 'fluent-cart') ] ] ], 'subscription' => [ 'label' => __('Subscriptions', 'fluent-cart'), 'options' => [ [ 'value' => 'subscription_activated', 'label' => __('Subscription Activated', 'fluent-cart') ], [ 'value' => 'subscription_reactivated', 'label' => __('Subscription Reactivated', 'fluent-cart') ], [ 'value' => 'subscription_canceled', 'label' => __('Subscription Canceled', 'fluent-cart') ], [ 'value' => 'subscription_renewed', 'label' => __('Subscription Renewed', 'fluent-cart') ], [ 'value' => 'subscription_eot', 'label' => __('Subscription End of Term (Completed)', 'fluent-cart') ], [ 'value' => 'subscription_expired_validity', 'label' => __('Subscription Expired / End of Access Validity', 'fluent-cart') ] ] ], 'product' => [ 'label' => __('Shipping', 'fluent-cart'), 'options' => [ [ 'value' => 'shipping_status_changed_to_shipped', 'label' => __('Order Shipped', 'fluent-cart') ], [ 'value' => 'shipping_status_changed_to_delivered', 'label' => __('Order Delivered', 'fluent-cart') ] ] ] ], 'inline_tip' => __('Select in which event you want to trigger this feed', 'fluent-cart'), 'label' => __('Event Trigger', 'fluent-cart'), 'placeholder' => __('Select Event', 'fluent-cart'), 'component' => 'selection_group', 'checkbox_label' => __('Event Trigger For This Feed', 'fluent-cart'), ]; } // Additional statuses can be added here as needed }