• Resolved yuyodev

    (@yuyodev)


    Hi,

    Is there a way to use Advanced Free Shipping with points?

    Specifically, I am using the Points and Rewards for WooCommerce plugin to manage customers’ points, but when customers use their points they do not get free shipping even though they meet the Advanced Free Shipping rate requirements.

    Does Advanced Free Shipping offer a way to get free shipping even when using points?

    Thank you,

    Takahiro

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi Takahiro,

    This can be accomplished through a custom condition.?Feel free to reach out through my website if you need help with this.

    Cheers,
    Jeroen

    Thread Starter yuyodev

    (@yuyodev)

    Hi Jeroen, thank you for your reply. I added the following code to functions.php as documented, but the points does not appear in the dropdown under Conditions. Do you know what the problem is?

    /**
    * Add condition to conditions list.
    *
    * @param array $conditions List of existing conditions.
    * @return aray List of modified conditions.
    */
    function was_conditions_add_points( $conditions ) {

    // 'General', 'User Details', 'Cart' are default groups, you can also use something custom
    $conditions['Cart']['points'] = __( 'Points', 'woocommerce-advanced-shipping' );

    return $conditions;

    }
    add_filter( 'was_conditions', 'was_conditions_add_points', 10, 1 );

    /**
    * Add value field for 'date' condition
    *
    * @param array $values List of value field arguments
    * @param string $condition Name of the condition.
    * @return array $values List of modified value field arguments.
    */
    function was_values_add_points( $values, $condition ) {

    switch ( $condition ) {

    case 'points':
    $values['field'] = 'text';
    $values['placeholder'] = '0';

    // Option 2; Drop down value field
    //
    // $values['field'] = 'select';
    //
    // foreach ( array( '1', '2' ) as $key => $value ) :
    // $values['options'][ $key ] = $value;
    // endforeach;

    break;

    }

    return $values;

    }
    add_filter( 'was_values', 'was_values_add_points', 10, 2 );

    /**
    * Must match given date.
    *
    * @param bool $match Current matching status. Default false.
    * @param string $operator Store owner selected operator.
    * @param mixed $value Store owner given value.
    * @param array $package Shipping package.
    * @return bool If the current user/environment matches this condition.
    */
    function was_match_condition_points( $match, $operator, $value, $package ) {

    // Check if its a date, when false subtract the number of days
    if ( $value > 0 ) :

    if ( $operator == '==' ) :
    $match = ( $value == $value);
    elseif ( $operator == '!=' ) :
    $match = ( $value != $value);
    elseif ( $operator == '>=' ) :
    $match = ( $value >= $value);
    elseif ( $operator == '<=' ) :
    $match = ( $value <= $value );
    endif;

    endif;

    return $match;

    }
    add_action( 'was_match_condition_points', 'was_match_condition_points', 10, 4 );

    /**
    * Add date description.
    *
    * @param array $description List of existing descriptions.
    * @return array List of modified descriptions.
    */
    function was_descriptions_points( $descriptions ) {

    $descriptions['points'] = __( 'points use', 'woocommerce-advanced-shipping' );

    return $descriptions;

    }
    add_filter( 'was_descriptions', 'was_descriptions_points' );
    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Sorry, I see I forgot to mention in my previous comment that the doc is for the Advanced Shipping?plugin, its very similar, but you’d have to look up the correct hook/filter names for this plugin.

    Cheers,
    Jeroen

    Thread Starter yuyodev

    (@yuyodev)

    Hi,

    I have solved some problems by rewriting the part in the documentation where it says “was” to “wafs”. The issue now is how to detect point usage handled by another plugin and pass it to this plugin as a condition, but I will give it a try.

    Thank you,

    Takahiro

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.