function qpp_coupon_codes($id) { qpp_change_form_update(); if (isset($_POST['Submit']) && check_admin_referer("save_qpp")) { $arr = array('couponnumber', 'couponget', 'duplicate', 'couponerror'); foreach ($arr as $item) { $coupon[$item] = stripslashes($_POST[$item]); $coupon[$item] = filter_var($coupon[$item], FILTER_SANITIZE_STRING); } $options = array('code', 'coupontype', 'couponpercent', 'couponfixed'); if ($coupon['couponnumber'] < 1) { $coupon['couponnumber'] = 1; } for ($i = 1; $i <= $coupon['couponnumber']; $i++) { foreach ($options as $item) { $coupon[$item . $i] = stripslashes($_POST[$item . $i]); } if (!$coupon['coupontype' . $i]) { $coupon['coupontype' . $i] = 'percent' . $i; } if (!$coupon['couponpercent' . $i]) { $coupon['couponpercent' . $i] = '10'; } if (!$coupon['couponfixed' . $i]) { $coupon['couponfixed' . $i] = '5'; } } update_option('qpp_coupon' . $id, $coupon); if ($coupon['duplicate']) { $qpp_setup = qpp_get_stored_setup(); $arr = explode(",", $qpp_setup['alternative']); foreach ($arr as $item) { update_option('qpp_coupon' . $item, $coupon); } } qpp_admin_notice("The coupon settings have been updated."); } if (isset($_POST['Reset']) && check_admin_referer("save_qpp")) { delete_option('qpp_coupon' . $id); qpp_admin_notice("The coupon settings have been reset."); } $qpp_setup = qpp_get_stored_setup(); $id = $qpp_setup['current']; $currency = qpp_get_stored_curr(); $before = array('USD' => '$', 'CDN' => '$', 'EUR' => '€', 'GBP' => '£', 'JPY' => '¥', 'AUD' => '$', 'BRL' => 'R$', 'HKD' => '$', 'ILS' => '₪', 'MXN' => '$', 'NZD' => '$', 'PHP' => '₱', 'SGD' => '$', 'TWD' => 'NT$', 'TRY' => '£'); $after = array('CZK' => 'Kč', 'DKK' => 'Kr', 'HUF' => 'Ft', 'MYR' => 'RM', 'NOK' => 'kr', 'PLN' => 'zł', 'RUB' => 'Руб', 'SEK' => 'kr', 'CHF' => 'CHF', 'THB' => '฿'); foreach ($before as $item => $key) { if ($item == $currency[$id]) { $b = $key; } } foreach ($after as $item => $key) { if ($item == $currency[$id]) { $a = $key; } } $coupon = qpp_get_stored_coupon($id); $content = '<div class="qpp-settings"><div class="qpp-options">'; if ($id) { $content .= '<h2>Coupons codes for ' . $id . '</h2>'; } else { $content .= '<h2>Default form coupons codes</h2>'; } $content .= qpp_change_form($qpp_setup); $content .= '<form method="post" action=""> <p<span<b>Note:</b> Leave fields blank if you don\'t want to use them</span></p> <p>Number of Coupons: <input type="text" name="couponnumber" value="' . $coupon['couponnumber'] . '" style="width:4em"></p> <table> <tr><td>Coupon Code</td><td>Percentage</td><td>Fixed Amount</td></tr>'; for ($i = 1; $i <= $coupon['couponnumber']; $i++) { $percent = $coupon['coupontype' . $i] == 'percent' . $i ? 'checked' : ''; $fixed = $coupon['coupontype' . $i] == 'fixed' . $i ? 'checked' : ''; $content .= '<tr><td><input type="text" name="code' . $i . '" value="' . $coupon['code' . $i] . '" /></td> <td><input style="margin:0; padding:0; border:none;" type="radio" name="coupontype' . $i . '" value="percent' . $i . '" ' . $percent . ' /> <input type="text" style="width:4em;padding:2px" label="couponpercent' . $i . '" name="couponpercent' . $i . '" value="' . $coupon['couponpercent' . $i] . '" /> %</td> <td><input style="margin:0; padding:0; border:none;" type="radio" name="coupontype' . $i . '" value="fixed' . $i . '" ' . $fixed . ' /> ' . $b . ' <input type="text" style="width:4em;padding:2px" label="couponfixed' . $i . '" name="couponfixed' . $i . '" value="' . $coupon['couponfixed' . $i] . '" /> ' . $a . '</td></tr>'; } $content .= '</table> <h2>Invalid Coupon Code Message</h2> <input id="couponerror" type="text" name="couponerror" value="' . $coupon['couponerror'] . '" /></p> <h2>Coupon Code Autofill</h2> <p>You can add coupon codes to URLs which will autofill the field. The URL format is: mysite.com/mypaymentpage/?coupon=code. The code you set will appear on the form with the following caption:<br> <input id="couponget" type="text" name="couponget" value="' . $coupon['couponget'] . '" /></p> <h2>Clone Coupon Settings</h2> <p><input type="checkbox" style="margin:0; padding: 0; border: none" name="duplicate" ' . $coupon['duplicate'] . ' value="checked" /> Duplicate coupon codes across all forms</p> <p><input type="submit" name="Submit" class="button-primary" style="color: #FFF;" value="Save Changes" /> <input type="submit" name="Reset" class="button-primary" style="color: #FFF;" value="Reset" onclick="return window.confirm( \'Are you sure you want to reset the coupon codes?\' );"/></p>'; $content .= wp_nonce_field("save_qpp"); $content .= '</form> </div> <div class="qpp-options" style="float:right;"> <h2>Coupon Check</h2> <p>Test your coupon codes.</p>'; if ($id) { $form = ' form="' . $id . '"'; } $args = array('form' => $id, 'id' => '', 'amount' => ''); $content .= qpp_loop($args); $content .= '<p>There are some more examples of payment forms <a href="http://quick-plugins.com/quick-paypal-payments/paypal-examples/" target="_blank">on this page</a>.</p> <p>And there are loads of shortcode options <a href="http://quick-plugins.com/quick-paypal-payments/paypal-payments-shortcodes/" target="_blank">on this page</a>.</p> </div></div>'; echo $content; }
function qpp_currency($id) { $currency = qpp_get_stored_curr(); $c = array(); $c['a'] = $c['b'] = ''; $before = array('USD' => '$', 'CDN' => '$', 'EUR' => '€', 'GBP' => '£', 'JPY' => '¥', 'AUD' => '$', 'BRL' => 'R$', 'HKD' => '$', 'ILS' => '₪', 'MXN' => '$', 'NZD' => '$', 'PHP' => '₱', 'SGD' => '$', 'TWD' => 'NT$', 'TRY' => '£'); $after = array('CZK' => 'Kč', 'DKK' => 'Kr', 'HUF' => 'Ft', 'MYR' => 'RM', 'NOK' => 'kr', 'PLN' => 'zł', 'RUB' => 'Руб', 'SEK' => 'kr', 'CHF' => 'CHF', 'THB' => '฿'); foreach ($before as $item => $key) { if ($item == $currency[$id]) { $c['b'] = $key; } } foreach ($after as $item => $key) { if ($item == $currency[$id]) { $c['a'] = $key; } } return $c; }