当前位置: 首页>>代码示例>>PHP>>正文


PHP pmpro_checkDiscountCode函数代码示例

本文整理汇总了PHP中pmpro_checkDiscountCode函数的典型用法代码示例。如果您正苦于以下问题:PHP pmpro_checkDiscountCode函数的具体用法?PHP pmpro_checkDiscountCode怎么用?PHP pmpro_checkDiscountCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pmpro_checkDiscountCode函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_coupon_affiliate_id

 /**
  * Get the affiliate associated with a coupon
  *
  * @access  public
  * @since   1.7.5
  */
 public function get_coupon_affiliate_id($coupon_code)
 {
     global $wpdb;
     $affiliate_id = false;
     if (!empty($coupon_code) && pmpro_checkDiscountCode($coupon_code)) {
         $table = $wpdb->prefix . 'affiliate_wp_affiliatemeta';
         $affiliate_id = $wpdb->get_var($wpdb->prepare("SELECT affiliate_id FROM {$table} WHERE meta_value = %s", $coupon_code));
     }
     return $affiliate_id;
 }
开发者ID:pmgarman,项目名称:AffiliateWP,代码行数:16,代码来源:class-pmp.php

示例2: apply_filters

if (pmpro_getOption("gateway", true) == "paypal") {
    $valid_gateways = apply_filters("pmpro_valid_gateways", array("paypal", "paypalexpress"));
} else {
    $valid_gateways = apply_filters("pmpro_valid_gateways", array(pmpro_getOption("gateway", true)));
}
//let's add an error now, if an invalid gateway is set
if (!in_array($gateway, $valid_gateways)) {
    $pmpro_msg = __("Invalid gateway.", 'pmpro');
    $pmpro_msgt = "pmpro_error";
}
//what level are they purchasing? (discount code passed)
if (!empty($_REQUEST['level']) && !empty($_REQUEST['discount_code'])) {
    $discount_code = preg_replace("/[^A-Za-z0-9\\-]/", "", $_REQUEST['discount_code']);
    $discount_code_id = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_discount_codes} WHERE code = '" . $discount_code . "' LIMIT 1");
    //check code
    $code_check = pmpro_checkDiscountCode($discount_code, (int) $_REQUEST['level'], true);
    if ($code_check[0] == false) {
        //error
        $pmpro_msg = $code_check[1];
        $pmpro_msgt = "pmpro_error";
        //don't use this code
        $use_discount_code = false;
    } else {
        $sqlQuery = "SELECT l.id, cl.*, l.name, l.description, l.allow_signups FROM {$wpdb->pmpro_discount_codes_levels} cl LEFT JOIN {$wpdb->pmpro_membership_levels} l ON cl.level_id = l.id LEFT JOIN {$wpdb->pmpro_discount_codes} dc ON dc.id = cl.code_id WHERE dc.code = '" . $discount_code . "' AND cl.level_id = '" . (int) $_REQUEST['level'] . "' LIMIT 1";
        $pmpro_level = $wpdb->get_row($sqlQuery);
        //if the discount code doesn't adjust the level, let's just get the straight level
        if (empty($pmpro_level)) {
            $pmpro_level = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_membership_levels} WHERE id = '" . (int) $_REQUEST['level'] . "' LIMIT 1");
        }
        //filter adjustments to the level
        $pmpro_level->code_id = $discount_code_id;
开发者ID:AmpleTech,项目名称:paid-memberships-pro,代码行数:31,代码来源:checkout.php

示例3: printf

			<td>
				<p>
					<?php 
printf(__('You have selected the <strong>%s</strong> membership level.', 'pmpro'), $pmpro_level->name);
?>
				</p>

				<?php 
if (!empty($pmpro_level->description)) {
    echo apply_filters("the_content", stripslashes($pmpro_level->description));
}
?>

				<div id="pmpro_level_cost">
					<?php 
if ($discount_code && pmpro_checkDiscountCode($discount_code)) {
    ?>
						<?php 
    printf(__('<p class="pmpro_level_discount_applied">The <strong>%s</strong> code has been applied to your order.</p>', 'pmpro'), $discount_code);
    ?>
					<?php 
}
?>
					<?php 
echo wpautop(pmpro_getLevelCost($pmpro_level));
?>
					<?php 
echo wpautop(pmpro_getLevelExpiration($pmpro_level));
?>
				</div>
开发者ID:mathieuhays,项目名称:paid-memberships-pro,代码行数:30,代码来源:checkout.php

示例4: preg_replace

} else {
    $discount_code = "";
    $discount_code_id = "";
}
if (!empty($_REQUEST['level'])) {
    $level_id = (int) $_REQUEST['level'];
} else {
    $level_id = NULL;
}
if (!empty($_REQUEST['msgfield'])) {
    $msgfield = preg_replace("/[^A-Za-z0-9\\_\\-]/", "", $_REQUEST['msgfield']);
} else {
    $msgfield = NULL;
}
//check that the code is valid
$codecheck = pmpro_checkDiscountCode($discount_code, $level_id, true);
if ($codecheck[0] == false) {
    //uh oh. show code error
    echo pmpro_no_quotes($codecheck[1]);
    ?>
		<script>			
			jQuery('#<?php 
    echo $msgfield;
    ?>
').show();
			jQuery('#<?php 
    echo $msgfield;
    ?>
').removeClass('pmpro_success');
			jQuery('#<?php 
    echo $msgfield;
开发者ID:AmpleTech,项目名称:paid-memberships-pro,代码行数:31,代码来源:applydiscountcode.php

示例5: pmpro_getLevelAtCheckout

/**
 * Get level at checkout and place into $pmpro_level global.
 */
function pmpro_getLevelAtCheckout($level_id = NULL, $discount_code = NULL)
{
    global $pmpro_level, $wpdb, $post;
    //reset pmpro_level
    $pmpro_level = NULL;
    //default to level passed in via URL
    if (empty($level_id) && !empty($_REQUEST['level'])) {
        $level_id = intval($_REQUEST['level']);
    }
    //default to discount code passed in
    if (empty($discount_code) && !empty($_REQUEST['discount_code'])) {
        $discount_code = preg_replace("/[^A-Za-z0-9\\-]/", "", $_REQUEST['discount_code']);
    }
    //what level are they purchasing? (discount code passed)
    if (!empty($level_id) && !empty($discount_code)) {
        $discount_code_id = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_discount_codes} WHERE code = '" . $discount_code . "' LIMIT 1");
        //check code
        $code_check = pmpro_checkDiscountCode($discount_code, $level_id, true);
        if ($code_check[0] != false) {
            $sqlQuery = "SELECT l.id, cl.*, l.name, l.description, l.allow_signups FROM {$wpdb->pmpro_discount_codes_levels} cl LEFT JOIN {$wpdb->pmpro_membership_levels} l ON cl.level_id = l.id LEFT JOIN {$wpdb->pmpro_discount_codes} dc ON dc.id = cl.code_id WHERE dc.code = '" . $discount_code . "' AND cl.level_id = '" . $level_id . "' LIMIT 1";
            $pmpro_level = $wpdb->get_row($sqlQuery);
            //if the discount code doesn't adjust the level, let's just get the straight level
            if (empty($pmpro_level)) {
                $pmpro_level = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_membership_levels} WHERE id = '" . $level_id . "' LIMIT 1");
            }
            //filter adjustments to the level
            $pmpro_level->code_id = $discount_code_id;
            $pmpro_level = apply_filters("pmpro_discount_code_level", $pmpro_level, $discount_code_id);
        }
    }
    //what level are they purchasing? (no discount code)
    if (empty($pmpro_level) && !empty($level_id)) {
        $pmpro_level = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_membership_levels} WHERE id = '" . esc_sql($level_id) . "' AND allow_signups = 1 LIMIT 1");
    } elseif (empty($pmpro_level)) {
        //check if a level is defined in custom fields
        $default_level = get_post_meta($post->ID, "pmpro_default_level", true);
        if (!empty($default_level)) {
            $pmpro_level = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_membership_levels} WHERE id = '" . esc_sql($default_level) . "' AND allow_signups = 1 LIMIT 1");
        }
    }
    //filter the level (for upgrades, etc)
    $pmpro_level = apply_filters("pmpro_checkout_level", $pmpro_level);
    return $pmpro_level;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:47,代码来源:functions.php

示例6: memberlite_levels_shortcode

function memberlite_levels_shortcode($atts, $content = null, $code = "")
{
    // $atts    ::= array of attributes
    // $content ::= text within enclosing form of shortcode element
    // $code    ::= the shortcode found, when == callback name
    // examples: [memberlite_levels levels="1,2,3" layout="table" hightlight="2" description="false" checkout_button="Register Now"]
    extract(shortcode_atts(array('account_button' => 'Your Level', 'back_link' => '1', 'checkout_button' => 'Select', 'compare' => NULL, 'description' => '1', 'discount_code' => NULL, 'expiration' => '1', 'highlight' => NULL, 'layout' => 'div', 'levels' => NULL, 'more_button' => NULL, 'price' => 'short', 'renew_button' => 'Renew'), $atts));
    global $wpdb, $pmpro_msg, $pmpro_msgt, $current_user, $pmpro_currency_symbol, $pmpro_all_levels, $pmpro_visible_levels, $current_user, $membership_levels;
    //turn 0's into falses
    if ($back_link === "0" || $back_link === "false" || $back_link === "no") {
        $back_link = false;
    } else {
        $back_link = true;
    }
    if ($compare === "0" || $compare === "false" || $compare === "no") {
        $compare = false;
    } else {
        $compareitems = explode(";", $compare);
    }
    if ($description === "0" || $description === "false" || $description === "no") {
        $description = false;
    } else {
        $description = true;
    }
    if ($expiration === "0" || $expiration === "false" || $expiration === "no") {
        $expiration = false;
    } else {
        $expiration = true;
    }
    if ($more_button === "0" || $more_button === "false" || $more_button === "no" || empty($more_button)) {
        $more_button = false;
    } elseif ($more_button === "1" || $more_button === "true" || $more_button === "yes") {
        $more_button = "Read More";
    }
    if ($price === "0" || $price === "false" || $price === "hide") {
        $show_price = false;
    } else {
        $show_price = true;
    }
    if (function_exists('pmpro_getAllLevels')) {
        ob_start();
        //make sure pmpro_levels has all levels
        if (!isset($pmpro_all_levels)) {
            $pmpro_all_levels = pmpro_getAllLevels(true, true);
        }
        if (!isset($pmpro_visible_levels)) {
            $pmpro_visible_levels = pmpro_getAllLevels(false, true);
        }
        if ($pmpro_msg) {
            ?>
			<div class="pmpro_message <?php 
            echo $pmpro_msgt;
            ?>
"><?php 
            echo $pmpro_msg;
            ?>
</div>
			<?php 
        }
        $pmpro_levels_filtered = array();
        if (!empty($levels)) {
            $levels_order = explode(",", $levels);
            //loop through $levels_order array and pull levels from $levels
            foreach ($levels_order as $level_id) {
                foreach ($pmpro_all_levels as $level) {
                    if ($level->id == $level_id) {
                        $pmpro_levels_filtered[$level->id] = $level;
                        break;
                    }
                }
            }
        } else {
            $pmpro_levels_filtered = $pmpro_visible_levels;
        }
        $pmpro_levels_filtered = apply_filters("pmpro_levels_array", $pmpro_levels_filtered);
        $numeric_levels_array = array_values($pmpro_levels_filtered);
        //update per discount code
        if (!empty($discount_code) && !empty($pmpro_levels_filtered)) {
            foreach ($pmpro_levels_filtered as $level_id => $level) {
                //check code for this level and update if applicable
                if (pmpro_checkDiscountCode($discount_code, $level->id)) {
                    $sqlQuery = "SELECT l.id, cl.*, l.name, l.description, l.allow_signups FROM {$wpdb->pmpro_discount_codes_levels} cl LEFT JOIN {$wpdb->pmpro_membership_levels} l ON cl.level_id = l.id LEFT JOIN {$wpdb->pmpro_discount_codes} dc ON dc.id = cl.code_id WHERE dc.code = '" . $discount_code . "' AND cl.level_id = '" . (int) $level->id . "' LIMIT 1";
                    $pmpro_levels_filtered[$level_id] = $wpdb->get_row($sqlQuery);
                    $pmpro_levels_filtered[$level_id]->base_level = $level;
                }
            }
        }
        if ($layout == 'table') {
            ?>
			<table id="pmpro_levels" class="pmpro_levels-table">
			<thead>
			  <tr>
				<th><?php 
            _e('Level', 'pmpro');
            ?>
</th>
				<?php 
            if (!empty($show_price)) {
                ?>
					<th><?php 
//.........这里部分代码省略.........
开发者ID:greathmaster,项目名称:memberlite,代码行数:101,代码来源:levels.php

示例7: apply_filters

 } else {
     $enddate = "NULL";
 }
 /**
  * Filter the end date for the membership/subscription.
  *
  * @since 1.8.9
  *
  * @param string $enddate , datetime formatsted for MySQL (YYYY-MM-DD)
  * @param int $user_id , ID of the user checking out
  * @param object $pmpro_level , object of level being checked out for
  * @param string $startdate , startdate calculated above
  */
 $enddate = apply_filters("pmpro_checkout_end_date", $enddate, $user_id, $pmpro_level, $startdate);
 //check code before adding it to the order
 $code_check = pmpro_checkDiscountCode($discount_code, $pmpro_level->id, true);
 if ($code_check[0] == false) {
     //error
     $pmpro_msg = $code_check[1];
     $pmpro_msgt = "pmpro_error";
     //don't use this code
     $use_discount_code = false;
 } else {
     //all okay
     $use_discount_code = true;
 }
 //update membership_user table.
 if (!empty($discount_code) && !empty($use_discount_code)) {
     $discount_code_id = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_discount_codes} WHERE code = '" . esc_sql($discount_code) . "' LIMIT 1");
 } else {
     $discount_code_id = "";
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:31,代码来源:checkout.php

示例8: pmpro_affiliates_set_discount_code

function pmpro_affiliates_set_discount_code()
{
    global $wpdb;
    //checkout page
    if (!isset($_REQUEST['discount_code']) && (!empty($_COOKIE['pmpro_affiliate']) || !empty($_REQUEST['pa']))) {
        if (!empty($_COOKIE['pmpro_affiliate'])) {
            $affiliate_code = $_COOKIE['pmpro_affiliate'];
        } else {
            $affiliate_code = $_REQUEST['pa'];
        }
        //set the discount code if there is an affiliate cookie
        $exists = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_discount_codes} WHERE code = '" . $wpdb->escape($affiliate_code) . "' LIMIT 1");
        if (!empty($exists)) {
            //check that the code is applicable for this level
            $codecheck = pmpro_checkDiscountCode($affiliate_code, $_REQUEST['level']);
            if ($codecheck) {
                $_REQUEST['discount_code'] = $affiliate_code;
            }
        }
    } elseif (!empty($_REQUEST['discount_code']) && empty($_REQUEST['pa']) && empty($_COOKIE['pmpro_affiliate'])) {
        //set the affiliate id to the discount code
        $exists = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_affiliates} WHERE code = '" . $wpdb->escape($_REQUEST['discount_code']) . "' LIMIT 1");
        if (!empty($exists)) {
            //set the affiliate id passed in to the discount code
            $_REQUEST['pa'] = $_REQUEST['discount_code'];
            //set the cookie to the discount code
            $_COOKIE['pmpro_affiliate'] = $_REQUEST['discount_code'];
        }
    }
}
开发者ID:datalynk,项目名称:pmpro-affiliates,代码行数:30,代码来源:pmpro-affiliates.php


注:本文中的pmpro_checkDiscountCode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。