autoship_get_coupon_type_by_code (function)

( src/coupons.php) Function that takes the QPilot coupon $type as a parameter and returns the WooCommerce coupon type.

Function

/**
 * Returns the WC Coupon Type based on the supplied QPilot Coupon Type.
 *
 * @param string $type The QPilot coupon type to lookup.
 * @param bool $val True return key's value if exists. False return false for non-strings.
 * @return NULL|string|bool The WC Coupon type else false if it doesn't exist.
 */
function autoship_get_coupon_type_by_code( $type, $val = false ){

  $codes = apply_filters( 'autoship_coupon_types_by_code', array(
    'ReduceSubtotalByPercentage'  => 'percent',
    'ReduceSubtotalByAmount'      => 'fixed_cart',
    'ReduceShippingByAmount'      => NULL,
    'SetShippingToAmount'         => NULL
  ) );

  if ( $val )
  return array_key_exists( $type, $codes ) ? $codes[$type] : false;

  return isset( $codes[$type] ) ? $codes[$type] : false;

}

Still need help? Contact Us Contact Us