2Checkout Feed Meta

Introduction

The Feed Meta Object for the 2Checkout Add-On is an associative array with properties determining how the add-on should process the form submission.

$feed['meta'] = array(
    'feedName'                 => 'Example Feed Name',
    'transactionType'          => 'product',
    'paymentAmount'            => '10',
    'billingCycle_length'      => '1',
    'billingCycle_unit'        => 'month',
    'recurringTimes'           => '12',
    'setupFee_enabled'         => true,
    'setupFee'                 => '2',
    'feedCondition'            => true,
    'feed_condition_object'    => array( 
        'conditionalLogic' => array(
            'actionType' => 'show',
            'logicType'  => 'all',
            'rules'      => array(
                array(
                    'fieldId'  => '9',
                    'operator' => 'is',
                    'value'    => 'Approved',
                ),
            ),
        ),
    ),
    'subscription_name'        => 'Name',
);

Usage

We recommend accessing the $feed meta using the rgar() or rgars() functions, e.g.:

$conditional_logic_enabled = rgars( $feed, 'meta/feedCondition' );

if ( $conditional_logic_enabled ) {
    // Conditional logic is enabled for this feed.
    $logic_rules = rgars( $feed, 'meta/feed_condition_conditional_logic_object/conditionalLogic/rules' );
    foreach ( $logic_rules as $rule ) {
        // Process each conditional logic rule.
        $field_id  = rgar( $rule, 'fieldId' );
        $operator  = rgar( $rule, 'operator' );
        $value     = rgar( $rule, 'value' );
        // Example: Use $field_id, $operator, and $value in your logic.
    }
}

Properties

PropertyTypeDescription
feedNamestringA unique name for the feed.
transactionTypestringThe type of transaction: ‘product’ or ‘subscription’.
paymentAmountstringSpecifies the field or merge tag to use for the payment amount.
billingCycle_lengthstringSpecifies the length of the billing cycle for subscriptions.
billingCycle_unitstringSpecifies the unit of time for the billing cycle: ‘week’, ‘month’, or ‘year’.
recurringTimesstringNumber of billing cycles for a subscription (or leave empty for ongoing).
setupFee_enabledbooleanEnables a one-time setup fee for subscriptions.
setupFeestringSpecifies the field or merge tag to use for the setup fee amount.
feedConditionbooleanEnables conditional logic to determine if the feed should run.
feed_condition_objectarrayStores the conditional logic rules.
subscription_namestringSpecifies a custom name for the subscription.