• Resolved luboslives

    (@luboslives)


    Hi, is there a simple hook or method I can call to enable or disable a rule? And is there one to check on the rule’s status (enabled or disabled)?

    For example, I want to extend a sale on a certain category of items if someone buys one of those items before a timer expires. Here’s what I’m thinking of doing:

    on woocommerce_payment_complete

    if ( ! $discount_is_active( $discount_ID ) ) {
        return;
    }
    
    if ( $order_contains_my_category ) {
        // reset timer
    }

    on timer_expire

    disable_discount( $discount_ID )

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    Please, use class Database

    use ADP\BaseVersion\Includes\Common\Database;
    $rule = reset(Database::getRules( array("id"=>$rule_id));
    DataBase::storeRule( array('enabled' => 1 ), $rule_id );
    Thread Starter luboslives

    (@luboslives)

    Thanks @algolplus, I’ll give it a shot after I find a timer plugin that I can hook into.

    Plugin Author algol.plus

    (@algolplus)

    We already support “Date” cart conditions.

    Timers is planned feature for this plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Enable/Disable a rule programatically and check its status’ is closed to new replies.