Reward rule for August


  • Default avatar
    begoña    
     3 years ago
    0

    Hello,

    Now I have a rule that assigns a 5% reward, the rule has no Expiration date.

    Also the status that Triggers the rules is "shipped".

    What I want to do is that during the month of August (that the store will be closed) all orders have a 10% reward when they are shipped in September. But that the orders made from September have a 5% reward when they are shipped.
    In the tests I have done it does not work for me because the start and end date of the Reward Rule takes into account the date of change of status of the order and not the date of the order.

    Any way to get it working?

    Thank you very much.
  • Your avatar
    seyi    
     3 years ago
    0

    Hello,

    Just reviewed the code for Virtuemart.  The start date and expiration looks at the order creation date, not the date the order status was changed.
  • Default avatar
    begoña    
     3 years ago
    0

    Hello,

    I have not installed any module that modifies the operation of the orders of virtuemart.

    The rule ends on August 31st.
    The reward is assigned when the order is changed to Shipped.
    Orders are shipped on September 5.

    Will points be awarded?


    In my trials if I place an order while the rule is in effect, but I send it in when the rule has expired, the reward is not assigned.


    Is this the expected behavior?
  • Your avatar
    seyi    
     3 years ago
    0

    Ok, I see the issue here.  When filtering out rules to run, it uses the start/expiration date to make sure it is still a valid rule, which is the first part.  When testing orders on that rule, it uses the start/expiration on the order creation date.  Ok, I think the solution here would be to still run order rules that have expired, up to 30 days after expiration.  This should cover orders that are late changing.  Here is what you can try:

    in the file www/administrator/components/com_aworewards/aworewards/library/class-aworewards-library-reward.php, around line 1670 is this:

    <?php
            $current_date 
    AR()->helper->get_datenull'Y-m-d H:i:s''utc2utc' );
            $rules AR()->db->get_objectlist'
                SELECT r.*
                  FROM #__aworewards_rule r
                 WHERE r.estore="' 
    $this->estore '"
                   AND r.state="published"
                   AND r.rule_type="' 
    AR()->db->escape$rule_type ) . '"
                   AND ( (r.startdate IS NULL AND r.expiration IS NULL) OR
                         (r.expiration IS NULL AND r.startdate<="' 
    $current_date '") OR
                         (r.startdate IS NULL AND r.expiration>="' 
    $current_date '") OR
                         (r.startdate<="' 
    $current_date '"        AND r.expiration>="' $current_date '")
                       )
                   AND r.customer_type="'
    AR()->db->escape$customer_type ) . '"
                 GROUP BY r.id
                 ORDER BY r.ordering,r.id
            '
    'id' );
    ?>

    Please change it to this
    <?php
            $current_date 
    AR()->helper->get_datenull'Y-m-d H:i:s''utc2utc' );
            $current_date_exp $current_date;
            if ( $rule_type == 'order' ) {
                    $gmdate = new DateTime'now', new DateTimeZone'UTC' ) );
                    $gmdate->modify'-30 days' );
                    $current_date_exp $gmdate->format'Y-m-d H:i:s' );
            }
            $rules AR()->db->get_objectlist'
                SELECT r.*
                  FROM #__aworewards_rule r
                 WHERE r.estore="' 
    $this->estore '"
                   AND r.state="published"
                   AND r.rule_type="' 
    AR()->db->escape$rule_type ) . '"
                   AND ( (r.startdate IS NULL AND r.expiration IS NULL) OR
                         (r.expiration IS NULL AND r.startdate<="' 
    $current_date '") OR
                         (r.startdate IS NULL AND r.expiration>="' 
    $current_date_exp '") OR
                         (r.startdate<="' 
    $current_date '"        AND r.expiration>="' $current_date_exp '")
                       )
                   AND r.customer_type="'
    AR()->db->escape$customer_type ) . '"
                 GROUP BY r.id
                 ORDER BY r.ordering,r.id
            '
    'id' );
    ?>

    That should still process order rules 30 days after expiration.
  • Default avatar
    begoña    
     3 years ago
    0

    Thank you very much.
    I'm going to try it.

    Regards.
  • Default avatar
    begoña    
     3 years ago
    0


    Hello seyi,

    I have not been able to test it until today, but it is not working. No rules apply.

    In addition, the most similar code, which is not the same, is the following in line 1669


    $current_date = AR()->helper->get_date( null, 'Y-m-d H:i:s', 'utc2utc' );
    $rules = AR()->db->get_objectlist( '
        SELECT r.*
            FROM #__aworewards_rule r
            WHERE r.estore="' . $this->estore . '"
            AND r.state="published"
            AND r.rule_type="' . AR()->db->escape( $rule_type ) . '"
            AND ( (r.startdate IS NULL AND r.expiration IS NULL) OR
                    (r.expiration IS NULL AND r.startdate<="' . $current_date . '") OR
                    (r.startdate IS NULL AND r.expiration>="' . $current_date . '") OR
                    (r.startdate<="' . $current_date . '"        AND r.expiration>="' . $current_date . '")
                )
            AND r.customer_type="'. AR()->db->escape( $customer_type ) . '"
            GROUP BY r.id
            ORDER BY r.ordering,r.id
    ', 'id' );
  • Your avatar
    seyi    
     3 years ago
    0

    The above code was stripping some tags, it should look better now, please try it again.
  • Default avatar
    begoña    
     3 years ago
    0

    Thank you very much.
    Now it seems to be working fine.