• Resolved wattsyourwebsite

    (@wattsyourwebsite)


    I have followed thesteps on this page:

    https://publishpress.com/knowledge-base/technical-details/

    in the section entitled “How to schedule expirations programmatically”.

    The result is that the Category to expire to does not get checked.
    https://ibb.co/GvMkq99

    My code:

    function expire_product($postID, $session_date, $studio_id) {
    
    // From the session_date, set the Expiration Date as 45 minutes afterwards.
    $expiration_date = $session_date->modify('+45 minutes');
    $expiration_date->modify('-10 hours'); // Seems to be out by 10 hours
    $expiration_date_str = $expiration_date->format('Y-m-d H:i:s');
    // Get the Product Category ID from the studio id
    $past_categoryId = intval(get_user_meta($studio_id, 'champ_franchisee_categories_past', true));
    if (function_exists('postExpirator_init')) {
    
    $options = [
    'expireType' => 'category',
    'id' => $postID,
            'category' => $past_categoryId,
            'categoryTaxonomy' => 'product_cat'
            
    ];
    
    $timeStamp = date('U', strtotime($expiration_date_str));
    
    $tempstr=date('d/m/Y H:i:s', $timeStamp);
    _scheduleExpiratorEvent($postID, $timeStamp, $options);
    }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Riza Maulana Ardiyanto

    (@rizaardiyanto)

    Hi @wattsyourwebsite

    That method will schedule the post-expiration according to the params you set, but it won’t run the expiration directly and will run through cron task instead.

    In this case, does the task is running but not adding category or the task is not running at all?

    You see any scheduled task for that post on Future > Diagnostics > Current Cron Schedule

    While if the task is there and running but not adding the category, maybe you can try to change expireType => category to category-add

    Thanks,

    Plugin Support Riza Maulana Ardiyanto

    (@rizaardiyanto)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved. If you have any further questions, please reply again here, or you can start a new thread.

    Thanks,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Progammatically set expiration does not work’ is closed to new replies.