Exemple #1
0
    public function display()
    {
        global $wpdb, $nzshpcrt_gateways;
        $payment_gateway_names = get_option('payment_gateway_names');
        if (empty($nzshpcrt_gateways)) {
            $nzshpcrt_gateways = nzshpcrt_get_gateways();
        }
        ?>

		<div class='metabox-holder'>
			<input type='hidden' name='gateway_submits' value='true' />
			<input type='hidden' name='wpsc_gateway_settings' value='gateway_settings' />
			<?php 
        if (get_option('custom_gateway') == 1) {
            $custom_gateway_hide = "style='display:block;'";
            $custom_gateway1 = 'checked="checked"';
        } else {
            $custom_gateway_hide = "style='display:none;'";
            $custom_gateway2 = 'checked="checked"';
        }
        ?>
			<table id='wpsc-payment-gateway-settings' class='wpsc-edit-module-options'>
				<tr>
					<td>
						<div class='postbox'>
							<h3 class='hndle'><?php 
        _e('Select Payment Gateways', 'wpsc');
        ?>
</h3>
							<div class='inside'>
								<p><?php 
        _e('Activate the payment gateways that you want to make available to your customers by selecting them below.', 'wpsc');
        ?>
</p>
								<br />
								<?php 
        $selected_gateways = get_option('custom_gateway_options');
        foreach ($nzshpcrt_gateways as $gateway) {
            if (isset($gateway['admin_name'])) {
                $gateway['name'] = $gateway['admin_name'];
            }
            ?>

									<div class="wpsc-select-gateway">
										<div class='wpsc-gateway-actions'>
											<span class="edit">
													<a class='edit-payment-module' data-gateway-id="<?php 
            echo esc_attr($gateway['internalname']);
            ?>
" title="<?php 
            esc_attr_e("Edit this Payment Gateway's Settings", 'wpsc');
            ?>
" href='<?php 
            echo esc_url($this->get_gateway_settings_url($gateway['internalname']));
            ?>
'><?php 
            esc_html_e('Edit', 'wpsc');
            ?>
</a>
													<img src="<?php 
            echo esc_url(admin_url('images/wpspin_light.gif'));
            ?>
" class="ajax-feedback" title="" alt="" />
											</span>
									</div>
									<p>
										<input name='wpsc_options[custom_gateway_options][]' <?php 
            checked(in_array($gateway['internalname'], (array) $selected_gateways));
            ?>
 type='checkbox' value='<?php 
            echo esc_attr($gateway['internalname']);
            ?>
' id='<?php 
            echo esc_attr($gateway['internalname']);
            ?>
_id' />
										<label for='<?php 
            echo esc_attr($gateway['internalname']);
            ?>
_id'><?php 
            echo esc_attr($gateway['name']);
            ?>
</label>
									</p>
								</div>
					<?php 
        }
        ?>
								<div class='submit gateway_settings'>
									<input type='submit' value='<?php 
        esc_attr_e('Update &raquo;', 'wpsc');
        ?>
' name='updateoption' />
								</div>
								</div>
							</div>

								<h4><?php 
        _e('We Recommend', 'wpsc');
        ?>
</h4>
								<a style="border-bottom:none;" href="https://www.paypal.com/nz/mrb/pal=LENKCHY6CU2VY" target="_blank"><img src="<?php 
        echo WPSC_CORE_IMAGES_URL;
        ?>
/paypal-referal.gif" border="0" alt="<?php 
        esc_attr_e('Sign up for PayPal and start accepting credit card payments instantly.', 'wpsc');
        ?>
" /></a> <br /><br />
								<a style="border-bottom:none;" href="http://checkout.google.com/sell/?promo=seinstinct" target="_blank"><img src="https://checkout.google.com/buyer/images/google_checkout.gif" border="0" alt="<?php 
        esc_attr_e('Sign up for Google Checkout', 'wpsc');
        ?>
" /></a>

							</td>

							<?php 
        $this->display_payment_gateway_settings_form();
        ?>
				</tr>
			</table>
		</div>

	<?php 
    }
function wpsc_packing_slip($purchase_id)
{
    echo "<!DOCTYPE html><html><head><title>" . __('Packing Slip', 'wpsc') . "</title></head><body id='wpsc-packing-slip'>";
    global $wpdb;
    $purch_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`='" . $purchase_id . "'";
    $purch_data = $wpdb->get_row($purch_sql, ARRAY_A);
    //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>";
    $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase_id . "";
    $cart_log = $wpdb->get_results($cartsql, ARRAY_A);
    $j = 0;
    if ($cart_log != null) {
        echo "<div class='packing_slip'>\n\r";
        echo apply_filters('wpsc_packing_slip_header', '<h2>' . __('Packing Slip', 'wpsc') . "</h2>\n\r");
        echo "<strong>" . __('Order', 'wpsc') . " #</strong> " . $purchase_id . "<br /><br />\n\r";
        echo "<table>\n\r";
        $form_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE\t`log_id` = '" . (int) $purchase_id . "'";
        $input_data = $wpdb->get_results($form_sql, ARRAY_A);
        foreach ($input_data as $input_row) {
            $rekeyed_input[$input_row['form_id']] = $input_row;
        }
        if ($input_data != null) {
            $form_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1'", ARRAY_A);
            foreach ($form_data as $form_field) {
                switch ($form_field['type']) {
                    case 'country':
                        $delivery_region_count = $wpdb->get_var("SELECT COUNT(`regions`.`id`) FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('" . $wpdb->escape($purch_data['billing_country']) . "')");
                        if (is_numeric($purch_data['billing_region']) && $delivery_region_count > 0) {
                            echo "\t<tr><td>" . __('State', 'wpsc') . ":</td><td>" . wpsc_get_region($purch_data['billing_region']) . "</td></tr>\n\r";
                        }
                        echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                        break;
                    case 'delivery_country':
                        if (is_numeric($purch_data['shipping_region']) && $delivery_region_count > 0) {
                            echo "\t<tr><td>" . __('State', 'wpsc') . ":</td><td>" . wpsc_get_region($purch_data['shipping_region']) . "</td></tr>\n\r";
                        }
                        echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                        break;
                    case 'heading':
                        if ($form_field['name'] == "Hidden Fields") {
                            continue;
                        } else {
                            echo "\t<tr class='heading'><td colspan='2'><strong>" . wp_kses($form_field['name'], array()) . ":</strong></td></tr>\n\r";
                        }
                        break;
                    default:
                        if ($form_field['name'] == "Cupcakes") {
                            parse_str($rekeyed_input[$form_field['id']]['value'], $cupcakes);
                            foreach ($cupcakes as $product_id => $quantity) {
                                $product = get_post($product_id);
                                $string .= "(" . $quantity . ") " . $product->post_title . ", ";
                            }
                            $string = rtrim($string, ", ");
                            echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($string), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                        } else {
                            if ($form_field['name'] == "State" && !empty($purch_data['billing_region']) || $form_field['name'] == "State" && !empty($purch_data['billing_region'])) {
                                echo "";
                            } else {
                                echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                            }
                        }
                        break;
                }
            }
        } else {
            echo "\t<tr><td>" . __('Name', 'wpsc') . ":</td><td>" . $purch_data['firstname'] . " " . $purch_data['lastname'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . __('Address', 'wpsc') . ":</td><td>" . $purch_data['address'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . __('Phone', 'wpsc') . ":</td><td>" . $purch_data['phone'] . "</td></tr>\n\r";
            echo "\t<tr><td>" . __('Email', 'wpsc') . ":</td><td>" . $purch_data['email'] . "</td></tr>\n\r";
        }
        if (2 == get_option('payment_method')) {
            $gateway_name = '';
            $nzshpcrt_gateways = nzshpcrt_get_gateways();
            foreach ($nzshpcrt_gateways as $gateway) {
                if ($purch_data['gateway'] != 'testmode') {
                    if ($gateway['internalname'] == $purch_data['gateway']) {
                        $gateway_name = $gateway['name'];
                    }
                } else {
                    $gateway_name = __('Manual Payment', 'wpsc');
                }
            }
        }
        echo "</table>\n\r";
        do_action('wpsc_packing_slip_extra_info', $purchase_id);
        echo "<table class='packing_slip'>";
        echo "<tr>";
        echo " <th>" . __('Quantity', 'wpsc') . " </th>";
        echo " <th>" . __('Name', 'wpsc') . "</th>";
        echo " <th>" . __('Price', 'wpsc') . " </th>";
        echo " <th>" . __('Shipping', 'wpsc') . " </th>";
        echo '<th>' . __('Tax', 'wpsc') . '</th>';
        echo '</tr>';
        $endtotal = 0;
        $all_donations = true;
        $all_no_shipping = true;
        $file_link_list = array();
        foreach ($cart_log as $cart_row) {
            $alternate = "";
            $j++;
            if ($j % 2 != 0) {
                $alternate = "class='alt'";
            }
            // product ID will be $cart_row['prodid']. need to fetch name and stuff
            $variation_list = '';
            if ($cart_row['donation'] != 1) {
                $all_donations = false;
            }
            if ($cart_row['no_shipping'] != 1) {
                $shipping = $cart_row['pnp'] * $cart_row['quantity'];
                $total_shipping += $shipping;
                $all_no_shipping = false;
            } else {
                $shipping = 0;
            }
            $price = $cart_row['price'] * $cart_row['quantity'];
            $gst = $price - $price / (1 + $cart_row['gst'] / 100);
            if ($gst > 0) {
                $tax_per_item = $gst / $cart_row['quantity'];
            }
            echo "<tr {$alternate}>";
            echo " <td>";
            echo $cart_row['quantity'];
            echo " </td>";
            echo " <td>";
            echo $cart_row['name'];
            echo stripslashes($variation_list);
            echo " </td>";
            echo " <td>";
            echo wpsc_currency_display($price);
            echo " </td>";
            echo " <td>";
            echo wpsc_currency_display($shipping);
            echo " </td>";
            echo '<td>';
            echo wpsc_currency_display($cart_row['tax_charged']);
            echo '</td>';
            echo '</tr>';
        }
        echo "</table>";
        echo '<table class="packing-slip-totals">';
        echo '<tr><th>Base Shipping</th><td>' . wpsc_currency_display($purch_data['base_shipping']) . '</td></tr>';
        echo '<tr><th>Total Shipping</th><td>' . wpsc_currency_display($purch_data['base_shipping'] + $total_shipping) . '</td></tr>';
        //wpec_taxes
        if ($purch_data['wpec_taxes_total'] != 0.0) {
            echo '<tr><th>Taxes</th><td>' . wpsc_currency_display($purch_data['wpec_taxes_total']) . '</td></tr>';
        }
        echo '<tr><th>Total Price</th><td>' . wpsc_currency_display($purch_data['totalprice']) . '</td></tr>';
        echo '</table>';
        echo "</div>\n\r";
    } else {
        echo "<br />" . __('This users cart was empty', 'wpsc');
    }
}
Exemple #3
0
function wpsc_gateway_settings()
{
    //To update options
    if (isset($_POST['wpsc_options'])) {
        foreach ($_POST['wpsc_options'] as $key => $value) {
            if ($value != get_option($key)) {
                update_option($key, $value);
            }
        }
        unset($_POST['wpsc_options']);
    }
    if (isset($_POST['user_defined_name']) && is_array($_POST['user_defined_name'])) {
        $payment_gateway_names = get_option('payment_gateway_names');
        if (!is_array($payment_gateway_names)) {
            $payment_gateway_names = array();
        }
        $payment_gateway_names = array_merge($payment_gateway_names, (array) $_POST['user_defined_name']);
        update_option('payment_gateway_names', $payment_gateway_names);
    }
    $custom_gateways = get_option('custom_gateway_options');
    $nzshpcrt_gateways = nzshpcrt_get_gateways();
    foreach ($nzshpcrt_gateways as $gateway) {
        if (in_array($gateway['internalname'], $custom_gateways)) {
            if (isset($gateway['submit_function'])) {
                call_user_func_array($gateway['submit_function'], array());
                $changes_made = true;
            }
        }
    }
    if (isset($_POST['payment_gw']) && $_POST['payment_gw'] != null) {
        update_option('payment_gateway', $_POST['payment_gw']);
    }
}
function wpsc_user_details()
{
    global $wpdb, $user_ID, $wpsc_purchlog_statuses, $gateway_checkout_form_fields, $purchase_log, $col_count;
    $nzshpcrt_gateways = nzshpcrt_get_gateways();
    $i = 0;
    $subtotal = 0;
    do_action('wpsc_pre_purchase_logs');
    foreach ((array) $purchase_log as $purchase) {
        $status_state = "expand";
        $status_style = "display:none;";
        $alternate = "";
        $i++;
        if ($i % 2 != 0) {
            $alternate = "class='alt'";
        }
        echo "<tr {$alternate}>\n\r";
        echo " <td class='processed'>";
        echo "<a href='#' onclick='return show_details_box(\"status_box_" . $purchase['id'] . "\",\"log_expander_icon_" . $purchase['id'] . "\");'>";
        if (!empty($_GET['id']) && $_GET['id'] == $purchase['id']) {
            $status_state = "collapse";
            $status_style = "style='display: block;'";
        }
        echo "<img class='log_expander_icon' id='log_expander_icon_" . $purchase['id'] . "' src='" . WPSC_CORE_IMAGES_URL . "/icon_window_{$status_state}.gif' alt='' title='' />";
        echo "<span id='form_group_" . $purchase['id'] . "_text'>" . __('Details', 'wpsc') . "</span>";
        echo "</a>";
        echo " </td>\n\r";
        echo " <td>";
        echo date("jS M Y", $purchase['date']);
        echo " </td>\n\r";
        echo " <td>";
        $country = get_option('country_form_field');
        if ($purchase['shipping_country'] != '') {
            $billing_country = $purchase['billing_country'];
            $shipping_country = $purchase['shipping_country'];
        } elseif (!empty($country)) {
            $country_sql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = %d LIMIT 1", $purchase['id'], get_option('country_form_field'));
            $country_data = $wpdb->get_results($country_sql, ARRAY_A);
            $billing_country = $country_data[0]['value'];
            $shipping_country = $country_data[0]['value'];
        }
        echo wpsc_currency_display($purchase['totalprice'], array('display_as_html' => false));
        $subtotal += $purchase['totalprice'];
        echo " </td>\n\r";
        if (get_option('payment_method') == 2) {
            echo " <td>";
            $gateway_name = '';
            foreach ((array) $nzshpcrt_gateways as $gateway) {
                if ($purchase['gateway'] != 'testmode') {
                    if ($gateway['internalname'] == $purchase['gateway']) {
                        $gateway_name = $gateway['name'];
                    }
                } else {
                    $gateway_name = "Manual Payment";
                }
            }
            echo $gateway_name;
            echo " </td>\n\r";
        }
        echo "</tr>\n\r";
        echo "<tr>\n\r";
        echo " <td colspan='{$col_count}' class='details'>\n\r";
        echo "  <div id='status_box_" . $purchase['id'] . "' class='order_status' style=\"{$status_style}\">\n\r";
        echo "  <div>\n\r";
        //order status code lies here
        //check what $purchase['processed'] reflects in the $wpsc_purchlog_statuses array
        $status_name = wpsc_find_purchlog_status_name($purchase['processed']);
        echo "  <strong class='form_group'>" . __('Order Status', 'wpsc') . ":</strong>\n\r";
        echo $status_name . "<br /><br />";
        do_action('wpsc_user_log_after_order_status', $purchase);
        //written by allen
        $usps_id = get_option('usps_user_id');
        if ($usps_id != null) {
            $XML1 = "<TrackFieldRequest USERID=\"{$usps_id}\"><TrackID ID=\"" . $purchase['track_id'] . "\"></TrackID></TrackFieldRequest>";
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "http://secure.shippingapis.com/ShippingAPITest.dll?");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            $postdata = "API=TrackV2&XML=" . $XML1;
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
            $parser = new xml2array();
            $parsed = $parser->parse($result);
            $parsed = $parsed[0]['children'][0]['children'];
            if ($purchase['track_id'] != null) {
                echo "<br /><br />";
                echo " <strong class='form_group'>" . __('Shipping Address', 'wpsc') . "</strong>\n\r";
                echo "<table>";
                foreach ((array) $parsed as $parse) {
                    if ($parse['name'] == "TRACKSUMMARY") {
                        foreach ((array) $parse['children'] as $attrs) {
                            if ($attrs['name'] != "EVENT") {
                                $attrs['name'] = str_replace("EVENT", "", $attrs['name']);
                            }
                            $bar = ucfirst(strtolower($attrs['name']));
                            echo "<tr><td>" . $bar . "</td><td>" . $attrs['tagData'] . "</td></tr>";
                        }
                    }
                }
                echo "</table>";
            }
            echo "<br /><br />";
        }
        //end of written by allen
        //cart contents display starts here;
        echo "  <strong class='form_group'>" . __('Order Details', 'wpsc') . ":</strong>\n\r";
        $cartsql = $wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`= %d", $purchase['id']);
        $cart_log = $wpdb->get_results($cartsql, ARRAY_A);
        $j = 0;
        // /*
        if ($cart_log != null) {
            echo "<table class='logdisplay'>";
            echo "<tr class='toprow2'>";
            echo " <td>";
            _e('Name', 'wpsc');
            echo " </td>";
            echo " <td>";
            _e('Quantity', 'wpsc');
            echo " </td>";
            echo " <td>";
            _e('Price', 'wpsc');
            echo " </td>";
            echo " <td>";
            _e('GST', 'wpsc');
            echo " </td>";
            echo " <td>";
            _e('Shipping', 'wpsc');
            echo " </td>";
            echo " <td>";
            _e('Total', 'wpsc');
            echo " </td>";
            echo "</tr>";
            $gsttotal = false;
            $endtotal = $total_shipping = 0;
            foreach ((array) $cart_log as $cart_row) {
                $alternate = "";
                $j++;
                if ($j % 2 != 0) {
                    $alternate = "class='alt'";
                }
                $variation_list = '';
                $billing_country = !empty($country_data[0]['value']) ? $country_data[0]['value'] : '';
                $shipping_country = !empty($country_data[0]['value']) ? $country_data[0]['value'] : '';
                $shipping = $cart_row['pnp'];
                $total_shipping += $shipping;
                echo "<tr {$alternate}>";
                echo " <td>";
                echo $cart_row['name'];
                echo $variation_list;
                echo " </td>";
                echo " <td>";
                echo $cart_row['quantity'];
                echo " </td>";
                echo " <td>";
                $price = $cart_row['price'] * $cart_row['quantity'];
                echo wpsc_currency_display($price);
                echo " </td>";
                echo " <td>";
                $gst = $cart_row['tax_charged'];
                if ($gst > 0) {
                    $gsttotal += $gst;
                }
                echo wpsc_currency_display($gst, array('display_as_html' => false));
                echo " </td>";
                echo " <td>";
                echo wpsc_currency_display($shipping, array('display_as_html' => false));
                echo " </td>";
                echo " <td>";
                $endtotal += $price;
                echo wpsc_currency_display($shipping + $price, array('display_as_html' => false));
                echo " </td>";
                echo '</tr>';
            }
            echo "<tr >";
            echo " <td>";
            echo " </td>";
            echo " <td>";
            echo " </td>";
            echo " <td>";
            echo " <td>";
            echo " </td>";
            echo " </td>";
            echo " <td>";
            echo "<strong>" . __('Total Shipping', 'wpsc') . ":</strong><br />";
            echo "<strong>" . __('Total Tax', 'wpsc') . ":</strong><br />";
            echo "<strong>" . __('Final Total', 'wpsc') . ":</strong>";
            echo " </td>";
            echo " <td>";
            $total_shipping += $purchase['base_shipping'];
            $endtotal += $total_shipping;
            $endtotal += $purchase['wpec_taxes_total'];
            echo wpsc_currency_display($total_shipping, array('display_as_html' => false)) . "<br />";
            if ($gsttotal) {
                //if false then must be exclusive.. doesnt seem too reliable needs more testing
                echo wpsc_currency_display($gsttotal, array('display_as_html' => false)) . "<br />";
            } else {
                echo wpsc_currency_display($purchase['wpec_taxes_total'], array('display_as_html' => false)) . "<br />";
            }
            echo wpsc_currency_display($endtotal, array('display_as_html' => false));
            echo " </td>";
            echo '</tr>';
            echo "</table>";
            echo "<br />";
            echo "<strong>" . __('Customer Details', 'wpsc') . ":</strong>";
            echo "<table class='customer_details'>";
            $usersql = $wpdb->prepare("SELECT `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.value, `" . WPSC_TABLE_CHECKOUT_FORMS . "`.* FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` LEFT JOIN `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` ON `" . WPSC_TABLE_CHECKOUT_FORMS . "`.id = `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`form_id` WHERE `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.log_id = %d OR `" . WPSC_TABLE_CHECKOUT_FORMS . "`.type = 'heading' ORDER BY `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`checkout_order`", $purchase['id']);
            $formfields = $wpdb->get_results($usersql, ARRAY_A);
            if (!empty($formfields)) {
                foreach ((array) $formfields as $form_field) {
                    // If its a heading display the Name otherwise continue on
                    if ('heading' == $form_field['type']) {
                        echo "  <tr><td colspan='2'>" . $form_field['name'] . ":</td></tr>";
                        continue;
                    }
                    switch ($form_field['unique_name']) {
                        case 'shippingcountry':
                        case 'billingcountry':
                            $country = unserialize($form_field['value']);
                            if (is_array($country)) {
                                $country = $country[0];
                            } else {
                                $country = $form_field['value'];
                            }
                            echo "  <tr><td>" . $form_field['name'] . ":</td><td>" . $country . "</td></tr>";
                            break;
                        case 'billingstate':
                        case 'shippingstate':
                            if (is_numeric($form_field['value'])) {
                                $state = wpsc_get_state_by_id($form_field['value'], 'name');
                            } else {
                                $state = $form_field['value'];
                            }
                            echo "  <tr><td>" . $form_field['name'] . ":</td><td>" . $state . "</td></tr>";
                            break;
                        default:
                            echo "  <tr><td>" . $form_field['name'] . ":</td><td>" . esc_html($form_field['value']) . "</td></tr>";
                    }
                }
            }
            $payment_gateway_names = '';
            $payment_gateway_names = get_option('payment_gateway_names');
            foreach ((array) $payment_gateway_names as $gatewayname) {
                //if the gateway has a custom name
                if (!empty($gatewayname)) {
                    $display_name = $payment_gateway_names[$purchase_log[0]['gateway']];
                } else {
                    //if not fall back on default name
                    foreach ((array) $nzshpcrt_gateways as $gateway) {
                        if ($gateway['internalname'] == $purchase['gateway']) {
                            $display_name = $gateway['name'];
                        }
                    }
                }
            }
            echo "  <tr><td>" . __('Payment Method', 'wpsc') . ":</td><td>" . $display_name . "</td></tr>";
            echo "  <tr><td>" . __('Purchase #', 'wpsc') . ":</td><td>" . $purchase['id'] . "</td></tr>";
            if ($purchase['transactid'] != '') {
                echo "  <tr><td>" . __('Transaction Id', 'wpsc') . ":</td><td>" . $purchase['transactid'] . "</td></tr>";
            }
            echo "</table>";
        }
        echo "  </div>\n\r";
        echo "  </div>\n\r";
        echo " </td>\n\r";
        echo "</tr>\n\r";
    }
}
Exemple #5
0
function wpsc_gateway_settings()
{
    //To update options
    if (isset($_POST['wpsc_options'])) {
        foreach ($_POST['wpsc_options'] as $key => $value) {
            if ($value != get_option($key)) {
                update_option($key, $value);
            }
        }
        unset($_POST['wpsc_options']);
    }
    if (isset($_POST['user_defined_name']) && is_array($_POST['user_defined_name'])) {
        $payment_gateway_names = get_option('payment_gateway_names');
        if (!is_array($payment_gateway_names)) {
            $payment_gateway_names = array();
        }
        $payment_gateway_names = array_merge($payment_gateway_names, (array) $_POST['user_defined_name']);
        update_option('payment_gateway_names', $payment_gateway_names);
    }
    $custom_gateways = get_option('custom_gateway_options');
    $nzshpcrt_gateways = nzshpcrt_get_gateways();
    foreach ($nzshpcrt_gateways as $gateway) {
        if (in_array($gateway['internalname'], $custom_gateways)) {
            if (isset($gateway['submit_function'])) {
                call_user_func_array($gateway['submit_function'], array());
                $changes_made = true;
            }
        }
    }
    if (isset($_POST['payment_gw']) && $_POST['payment_gw'] != null) {
        update_option('payment_gateway', $_POST['payment_gw']);
    }
    $sendback = wp_get_referer();
    if (isset($updated)) {
        $sendback = add_query_arg('updated', $updated, $sendback);
    }
    if (isset($_SESSION['wpsc_settings_curr_page'])) {
        $sendback = add_query_arg('page', 'wpsc-settings', $sendback);
        $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
    }
    wp_redirect($sendback);
    exit;
}
Exemple #6
0
function wpsc_options_gateway()
{
    global $wpdb, $nzshpcrt_gateways;
    $curgateway = get_option('payment_gateway');
    $payment_gateway_names = get_option('payment_gateway_names');
    if (empty($nzshpcrt_gateways)) {
        $nzshpcrt_gateways = nzshpcrt_get_gateways();
    }
    if (is_array($nzshpcrt_gateways)) {
        $selected_gateways = get_option('custom_gateway_options');
        foreach ($nzshpcrt_gateways as $gateway) {
            if ($gateway['internalname'] == $curgateway) {
                $selected = "selected='selected'";
                $form = $gateway['form']();
                $selected_gateway_data = $gateway;
            } else {
                $selected = '';
            }
            if (isset($gateway['admin_name'])) {
                $gateway['name'] = $gateway['admin_name'];
            }
            $disabled = '';
            if (!in_array($gateway['internalname'], (array) $selected_gateways)) {
                $disabled = "disabled='disabled'";
            }
            if (!isset($gateway['internalname'])) {
                $gateway['internalname'] = '';
            }
            $gatewaylist = '';
            $gatewaylist .= "<option {$disabled} value='" . esc_attr($gateway['internalname']) . "' " . $selected . " >" . esc_attr($gateway['name']) . "</option>";
        }
    }
    $nogw = '';
    $gatewaylist = "<option value='" . $nogw . "'>" . __('Please Select A Payment Gateway', 'wpsc') . "</option>" . $gatewaylist;
    ?>

	<script language='javascript' type='text/javascript'>
		function selectgateway() {
			document.forms.gateway_opt.submit();
		}
	</script>

	<div class="wrap">
	<div class='metabox-holder'>
		<form name='gatewayopt' method='post' id='gateway_opt' action='' class='wpsc_form_track'>
			<input type='hidden' name='gateway_submits' value='true' />
			<input type='hidden' name='wpsc_gateway_settings' value='gateway_settings' />
			<?php 
    if (get_option('custom_gateway') == 1) {
        $custom_gateway_hide = "style='display:block;'";
        $custom_gateway1 = 'checked="checked"';
    } else {
        $custom_gateway_hide = "style='display:none;'";
        $custom_gateway2 = 'checked="checked"';
    }
    /* wpsc_setting_page_update_notification displays the wordpress styled notifications */
    wpsc_settings_page_update_notification();
    ?>
			<table id='gateway_options' >
				<tr>
					<td class='select_gateway'>
						<div class='postbox'>
							<h3 class='hndle'><?php 
    _e('General Settings', 'wpsc');
    ?>
</h3>
							<div class='inside'>
								<p><?php 
    _e('Activate the payment gateways that you want to make available to your customers by selecting them below.', 'wpsc');
    ?>
</p>
								<br />
								<?php 
    $selected_gateways = get_option('custom_gateway_options');
    foreach ($nzshpcrt_gateways as $gateway) {
        if (isset($gateway['admin_name'])) {
            $gateway['name'] = $gateway['admin_name'];
        }
        if (in_array($gateway['internalname'], (array) $selected_gateways)) {
            ?>

										<div class="wpsc_shipping_options">
											<div class='wpsc-shipping-actions wpsc-payment-actions'>
											| <span class="edit">
													<a class='edit-payment-module' rel="<?php 
            echo $gateway['internalname'];
            ?>
" onclick="event.preventDefault();" title="Edit this Payment Module" href='<?php 
            echo htmlspecialchars(add_query_arg('payment_module', $gateway['internalname']));
            ?>
' style="cursor:pointer;">Edit</a>
										</span> |
									</div>
									<p><input name='wpsc_options[custom_gateway_options][]' checked='checked' type='checkbox' value='<?php 
            esc_attr_e($gateway['internalname']);
            ?>
' id='<?php 
            esc_attr_e($gateway['internalname']);
            ?>
_id' />
										<label for='<?php 
            esc_attr_e($gateway['internalname']);
            ?>
_id'><?php 
            esc_attr_e($gateway['name']);
            ?>
</label></p>
								</div>
<?php 
        } else {
            ?>
										<div class="wpsc_shipping_options">
											<div class='wpsc-shipping-actions wpsc-payment-actions'>
											| <span class="edit">
													<a class='edit-payment-module' rel="<?php 
            echo $gateway['internalname'];
            ?>
" onclick="event.preventDefault();" title="Edit this Payment Module" href='<?php 
            echo htmlspecialchars(add_query_arg('payment_module', $gateway['internalname']));
            ?>
' style="cursor:pointer;"><?php 
            _e('Edit', 'wpsc');
            ?>
</a>
										</span> |
									</div>
									<p><input name='wpsc_options[custom_gateway_options][]' type='checkbox' value='<?php 
            echo $gateway['internalname'];
            ?>
' id='<?php 
            echo $gateway['internalname'];
            ?>
_id' />
										<label for='<?php 
            echo $gateway['internalname'];
            ?>
_id'><?php 
            echo $gateway['name'];
            ?>
</label></p></div>
								<?php 
        }
    }
    ?>
								<div class='submit gateway_settings'>
									<input type='hidden' value='true' name='update_gateways' />
									<input type='submit' value='<?php 
    _e('Update &raquo;', 'wpsc');
    ?>
' name='updateoption' />
								</div>
								</div>
							</div>

								<h4><?php 
    _e('We Recommend', 'wpsc');
    ?>
</h4>
								<a style="border-bottom:none;" href="https://www.paypal.com/nz/mrb/pal=LENKCHY6CU2VY" target="_blank"><img src="<?php 
    echo WPSC_CORE_IMAGES_URL;
    ?>
/paypal-referal.gif" border="0" alt="Sign up for PayPal and start accepting credit card payments instantly." /></a> <br /><br />
								<a style="border-bottom:none;" href="http://checkout.google.com/sell/?promo=seinstinct" target="_blank"><img src="https://checkout.google.com/buyer/images/google_checkout.gif" border="0" alt="Sign up for Google Checkout" /></a>

							</td>

							<td class='gateway_settings' rowspan='2'>
								<div class='postbox'>
							<?php 
    if (!isset($_SESSION['previous_payment_name'])) {
        $_SESSION['previous_payment_name'] = "";
    }
    if (!isset($selected_gateway_data)) {
        $selected_gateway_data = "";
    }
    $payment_data = wpsc_get_payment_form($_SESSION['previous_payment_name'], $selected_gateway_data);
    ?>
								<h3 class='hndle'><?php 
    echo $payment_data['name'];
    ?>
</h3>
								<div class='inside'>
								<table class='form-table'>
									<?php 
    echo $payment_data['form_fields'];
    ?>
								</table>
								<?php 
    if ($payment_data['has_submit_button'] == 0) {
        $update_button_css = 'style= "display: none;"';
    } else {
        $update_button_css = '';
    }
    ?>
								<div class='submit' <?php 
    echo $update_button_css;
    ?>
>
<?php 
    wp_nonce_field('update-options', 'wpsc-update-options');
    ?>
									<input type='submit' value='<?php 
    _e('Update &raquo;', 'wpsc');
    ?>
' name='updateoption' />
								</div>
							</div>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>

<?php 
}
Exemple #7
0
function print_packing_slip_data($input_data, $form_data, $purch_data, $rekeyed_input, $purchase_id_value)
{
    global $wpdb;
    if ($input_data != null) {
        foreach ($form_data as $form_field) {
            switch ($form_field['type']) {
                case 'country':
                    $delivery_region_count = $wpdb->get_var("SELECT COUNT(`regions`.`id`) FROM `" . WPSC_TABLE_REGION_TAX . "` AS `regions` INNER JOIN `" . WPSC_TABLE_CURRENCY_LIST . "` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('" . $wpdb->_real_escape($purch_data[$purchase_id_value]['billing_country']) . "')");
                    if (is_numeric($purch_data[$purchase_id_value]['billing_region']) && $delivery_region_count > 0) {
                        echo "\t<tr><td>" . __('State', 'wpsc') . ":</td><td> " . wpsc_get_region($purch_data[$purchase_id_value]['billing_region']) . "</td></tr>\n\r";
                    }
                    echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$purchase_id_value][$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                    break;
                case 'delivery_country':
                    if (is_numeric($purch_data[$purchase_id_value]['shipping_region']) && $delivery_region_count > 0) {
                        echo "\t<tr><td>" . __('State', 'wpsc') . ":</td><td> " . wpsc_get_region($purch_data[$purchase_id_value]['shipping_region']) . "</td></tr>\n\r";
                    }
                    echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($rekeyed_input[$purchase_id_value][$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                    break;
                case 'heading':
                    if ($form_field['name'] == "Hidden Fields") {
                        continue;
                    } else {
                        echo "<tr class='heading'><td colspan='2'><strong><u>" . wp_kses($form_field['name'], array()) . "</u>:</strong></td></tr>\n\r";
                    }
                    break;
                default:
                    if ($form_field['name'] == "Cupcakes") {
                        parse_str($rekeyed_input[$purchase_id_value][$form_field['id']]['value'], $cupcakes);
                        foreach ($cupcakes as $product_id => $quantity) {
                            $product = get_post($product_id);
                            $string .= "(" . $quantity . ") " . $product->post_title . ", ";
                        }
                        $string = rtrim($string, ", ");
                        echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . htmlentities(stripslashes($string), ENT_QUOTES, 'UTF-8') . "</td></tr>\n\r";
                    } else {
                        if ($form_field['name'] == "State" && !empty($purch_data[$purchase_id_value]['billing_region']) || $form_field['name'] == "State" && !empty($purch_data[$purchase_id_value]['billing_region'])) {
                            echo "";
                        } else {
                            echo "\t<tr><td>" . wp_kses($form_field['name'], array()) . ":</td><td>" . (isset($rekeyed_input[$purchase_id_value][$form_field['id']]) ? htmlentities(stripslashes($rekeyed_input[$purchase_id_value][$form_field['id']]['value']), ENT_QUOTES, 'UTF-8') : '') . "</td></tr>\n\r";
                        }
                    }
                    break;
            }
        }
    } else {
        echo "\t<tr><td>" . __('Name', 'wpsc') . ":</td><td> " . $purch_data[$purchase_id_value]['firstname'] . " " . $purch_data[$purchase_id_value]['lastname'] . "</td></tr>\n\r";
        echo "\t<tr><td>" . __('Address', 'wpsc') . ":</td><td> " . $purch_data[$purchase_id_value]['address'] . "</td></tr>\n\r";
        echo "\t<tr><td>" . __('Phone', 'wpsc') . ":</td><td> " . $purch_data[$purchase_id_value]['phone'] . "</td></tr>\n\r";
        echo "\t<tr><td>" . __('Email', 'wpsc') . ":</td><td> " . $purch_data[$purchase_id_value]['email'] . "</td></tr>\n\r";
    }
    if (2 == get_option('payment_method')) {
        $gateway_name = '';
        $nzshpcrt_gateways = nzshpcrt_get_gateways();
        foreach ($nzshpcrt_gateways as $gateway) {
            if ($purch_data[$purchase_id_value]['gateway'] != 'testmode') {
                if ($gateway['internalname'] == $purch_data[$purchase_id_value]['gateway']) {
                    $gateway_name = $gateway['name'];
                }
            } else {
                $gateway_name = __('Manual Payment', 'wpsc');
            }
        }
    }
}