Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

woocommerce-subscriptions

БесплатноБез исполняемых скриптовНе проверен

Add subscription products to WooCommerce with automatic recurring billing, renewal notifications, and subscriber self-service management

finsilabsот finsilabs★ 69 звёзд на GitHub

Об этом скилле

WooCommerce Subscriptions

Overview

WooCommerce Subscriptions (the official premium plugin) adds subscription product types — simple subscriptions and variable subscriptions — with configurable billing periods (daily, weekly, monthly, yearly), free trials, sign-up fees, and prorated upgrades/downgrades. It integrates with Stripe, PayPal Reference Transactions, and other gateways that support automated recurring billing. Custom logic hooks into the subscription lifecycle via a rich set of WordPress actions and filters.

When to Use This Skill

  • When selling products or services on a recurring billing schedule (SaaS, memberships, box subscriptions)
  • When implementing subscription upgrades, downgrades, or plan switching
  • When building custom renewal logic or adding business rules around failed payment retry
  • When integrating subscription status with access control (e.g., membership site content gates)
  • When extending subscription emails or admin reporting with custom data
  • When creating subscription add-ons or per-unit quantity scaling

Core Instructions

  1. Create a subscription product programmatically

    <?php
    // Create a simple subscription product via code (e.g., in a migration script)
    $product = new WC_Product_Subscription();
    $product->set_name('Monthly Pro Plan');
    $product->set_status('publish');
    $product->set_regular_price('29.99');
    
    // Save first so the product gets an ID
    $product->save();
    
    // Subscription-specific meta (product must be saved before setting post meta)
    update_post_meta($product->get_id(), '_subscription_price', '29.99');
    update_post_meta($product->get_id(), '_subscription_period', 'month');
    update_post_meta($product->get_id(), '_subscription_period_interval', '1');
    update_post_meta($product->get_id(), '_subscription_length', '0'); // 0 = forever
    update_post_meta($product->get_id(), '_subscription_trial_length', '14');
    update_post_meta($product->get_id(), '_subscription_trial_period', 'day');
    update_post_meta($product->get_id(), '_subscription_sign_up_fee', '0');
    
  2. Hook into subscription lifecycle events

    WooCommerce Subscriptions fires specific actions at each lifecycle stage:

    <?php
    
    // When a new subscription is created (after successful first payment)
    add_action('woocommerce_subscription_status_active', function ($subscription) {
        $user_id = $subscription->get_user_id();
        $plan = $subscription->get_items(); // Array of WC_Order_Item_Product
    
        // Grant access — e.g., set user role or update capabilities
        $user = new WP_User($user_id);
        $user->add_role('subscriber_member');
    
        // Track in analytics
        error_log("Subscription {$subscription->get_id()} activated for user {$user_id}");
    });
    
    // When a renewal payment succeeds
    add_action('woocommerce_subscription_renewal_payment_complete', function ($subscription, $last_order) {
        $user_id = $subscription->get_user_id();
        // Extend access, send renewal receipt, update CRM
        do_action('my_plugin_renewal_processed', $user_id, $subscription);
    }, 10, 2);
    
    // When a renewal payment fails
    add_action('woocommerce_subscription_payment_failed', function ($subscription, $last_order) {
        $user_id = $subscription->get_user_id();
        $retry_count = $subscription->get_failed_payment_count();
    
        // Notify user and optionally pause access
        if ($retry_count >= 2) {
            $user = new WP_User($user_id);
            $user->remove_role('subscriber_member');
            // Send dunning email
            $subscription->update_status('on-hold');
        }
    }, 10, 2);
    
    // When subscription is cancelled
    add_action('woocommerce_subscription_status_cancelled', function ($subscription) {
        $user_id = $subscription->get_user_id();
        $user = new WP_User($user_id);
        $user->remove_role('subscriber_member');
    });
    
  3. Query subscriptions programmatically

    <?php
    
    // Get all active subscriptions for a user
    function get_user_active_subscriptions(int $user_id): array {
        return wcs_get_users_subscriptions($user_id, ['active']);
    }
    
    // Check if a user has an active subscription to a specific product
    function user_has_active_subscription_to_product(int $user_id, int $product_id): bool {
        $subscriptions = wcs_get_subscriptions_for_product($product_id, 'any', ['customer_id' => $user_id]);
        foreach ($subscriptions as $subscription) {
            if ($subscription->has_status('active')) {
                return true;
            }
        }
        return false;
    }
    
    // Get subscription by ID
    function get_subscription_details(int $subscription_id): ?WC_Subscription {
        $subscription = wcs_get_subscription($subscription_id);
        if (!$subscription) return null;
    
        return $subscription;
    }
    
    // Usage
    $subscription = get_subscription_details(1234);
    if ($subscription) {
        echo
    
Полный SKILL.md на GitHub

Установить woocommerce-subscriptions в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

claude-code
cursor
gemini-cli
copilot
codex-cli
kiro
opencode

Вложенные файлы

evals/failed-payment-retry-suspension-and-rein/criteria.jsonevals/failed-payment-retry-suspension-and-rein/task.mdevals/plan-switching-with-proration-and-safe-c/criteria.jsonevals/plan-switching-with-proration-and-safe-c/task.mdevals/subscription-product-creation-and-lifecy/criteria.jsonevals/subscription-product-creation-and-lifecy/task.mdtile.json

FAQ

Что делает скилл woocommerce-subscriptions?

Add subscription products to WooCommerce with automatic recurring billing, renewal notifications, and subscriber self-service management

Как установить скилл woocommerce-subscriptions?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл woocommerce-subscriptions запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить woocommerce-subscriptions с