public function is_available() { if ($this->get_enabled() == "no") { return false; } if (isset(fflcommerce_cart::$cart_contents_total_ex_dl) && isset($this->min_amount) && $this->min_amount && apply_filters('fflcommerce_shipping_min_amount', $this->min_amount, $this) > fflcommerce_cart::$cart_contents_total_ex_dl - fflcommerce_cart::$discount_total) { return false; } if (is_array($this->get_ship_to_countries()) && !in_array(fflcommerce_customer::get_shipping_country(), $this->get_ship_to_countries())) { $this->set_error_message('Sorry, it seems that there are no available shipping methods to your location. Please contact us if you require assistance or wish to make alternate arrangements.'); return false; } return !$this->has_error; }
function fflcommerce_cart($atts) { unset(fflcommerce_session::instance()->selected_rate_id); // Process Discount Codes if (isset($_POST['apply_coupon']) && $_POST['apply_coupon'] && fflcommerce::verify_nonce('cart')) { $coupon_code = sanitize_title($_POST['coupon_code']); fflcommerce_cart::add_discount($coupon_code); } elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && fflcommerce::verify_nonce('cart')) { // Update Shipping unset(fflcommerce_session::instance()->chosen_shipping_method_id); $country = $_POST['calc_shipping_country']; $state = $_POST['calc_shipping_state']; $postcode = $_POST['calc_shipping_postcode']; if ($postcode && !fflcommerce_validation::is_postcode($postcode, $country)) { fflcommerce::add_error(__('Please enter a valid postcode/ZIP.', 'fflcommerce')); $postcode = ''; } elseif ($postcode) { $postcode = fflcommerce_validation::format_postcode($postcode, $country); } if ($country) { // Update customer location fflcommerce_customer::set_location($country, $state, $postcode); fflcommerce_customer::set_shipping_location($country, $state, $postcode); fflcommerce::add_message(__('Shipping costs updated.', 'fflcommerce')); } else { fflcommerce_customer::set_shipping_location('', '', ''); fflcommerce::add_message(__('Shipping costs updated.', 'fflcommerce')); } } elseif (isset($_POST['shipping_rates'])) { $rates_params = explode(":", $_POST['shipping_rates']); $available_methods = fflcommerce_shipping::get_available_shipping_methods(); $shipping_method = $available_methods[$rates_params[0]]; if ($rates_params[1] != null) { fflcommerce_session::instance()->selected_rate_id = $rates_params[1]; } $shipping_method->choose(); // chooses the method selected by user. } // Re-Calc prices. This needs to happen every time the cart page is loaded and after checking post results. fflcommerce_cart::calculate_totals(); $result = fflcommerce_cart::check_cart_item_stock(); if (is_wp_error($result)) { fflcommerce::add_error($result->get_error_message()); } fflcommerce_render('shortcode/cart', array('cart' => fflcommerce_cart::get_cart(), 'coupons' => fflcommerce_cart::get_coupons())); }
/** * Outputs a form field * * @param array $args contains a list of args for showing the field, merged with defaults (below) * @return string */ public static function address_form_field($args) { $defaults = array('type' => 'text', 'name' => '', 'label' => '', 'placeholder' => '', 'required' => false, 'class' => array(), 'label_class' => array(), 'rel' => '', 'return' => false, 'options' => array(), 'value' => ''); $args = wp_parse_args($args, $defaults); if ($args['required']) { $required = ' <span class="required">*</span>'; $input_required = ' input-required'; } else { $required = ''; $input_required = ''; } if (in_array('form-row-last', $args['class'])) { $after = '<div class="clear"></div>'; } else { $after = ''; } switch ($args['type']) { case "country": $current_c = self::get_value($args['name']); $is_shipping_c = strpos($args['name'], 'shipping'); if (!$current_c) { if ($is_shipping_c === false) { $current_c = fflcommerce_customer::get_country(); } else { $current_c = fflcommerce_customer::get_shipping_country(); } } // Remove 'Select a Country' option from drop-down menu for countries. // There is no need to have it, because was assume when user hasn't selected // a country that they are from the shop base country. $field = '<p class="form-row ' . implode(' ', $args['class']) . '"> <label for="' . esc_attr($args['name']) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label> <select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="country_to_state" rel="' . esc_attr($args['rel']) . '">'; foreach (fflcommerce_countries::get_allowed_countries() as $key => $value) { $field .= '<option value="' . esc_attr($key) . '"'; if (self::get_value($args['name']) == $key) { $field .= ' selected="selected"'; } elseif (self::get_value($args['name']) && $current_c == $key) { $field .= ' selected="selected"'; } $field .= '>' . __($value, 'fflcommerce') . '</option>'; } $field .= '</select></p>' . $after; break; case "state": $field = '<p class="form-row ' . implode(' ', $args['class']) . '"> <label for="' . esc_attr($args['name']) . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label>'; $is_shipping_s = strpos($args['name'], 'shipping'); $current_cc = self::get_value($args['rel']); if (!$current_cc) { if ($is_shipping_s === false) { $current_cc = fflcommerce_customer::get_country(); } else { $current_cc = fflcommerce_customer::get_shipping_country(); } } $current_r = self::get_value($args['name']); if (!$current_r) { if ($is_shipping_s === false) { $current_r = fflcommerce_customer::get_state(); } else { $current_r = fflcommerce_customer::get_shipping_state(); } } $states = fflcommerce_countries::get_states($current_cc); if (!empty($states)) { // Dropdown $field .= '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($input_required) . '"><option value="">' . __('Select a state…', 'fflcommerce') . '</option>'; foreach ($states as $key => $value) { $field .= '<option value="' . esc_attr($key) . '"'; if ($current_r == $key) { $field .= ' selected="selected"'; } $field .= '>' . __($value, 'fflcommerce') . '</option>'; } $field .= '</select>'; } else { // Input $field .= '<input type="text" class="input-text" value="' . esc_attr($current_r) . '" placeholder="' . __('State/Province', 'fflcommerce') . '" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" />'; } $field .= '</p>' . $after; break; case "postcode": $current_pc = self::get_value($args['name']); $is_shipping_pc = strpos($args['name'], 'shipping'); if (!$current_pc) { if ($is_shipping_pc === false) { $current_pc = fflcommerce_customer::get_postcode(); } else { $current_pc = fflcommerce_customer::get_shipping_postcode(); } } $field = '<p class="form-row ' . implode(' ', $args['class']) . '"> <label for="' . esc_attr($args['name']) . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label> <input type="text" class="input-text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" placeholder="' . $args['placeholder'] . '" value="' . esc_attr($current_pc) . '" /> </p>' . $after; break; case "textarea": $field = '<p class="form-row ' . implode(' ', $args['class']) . '"> <label for="' . esc_attr($args['name']) . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label> <textarea name="' . esc_attr($args['name']) . '" class="input-text' . esc_attr($input_required) . '" id="' . esc_attr($args['name']) . '" placeholder="' . $args['placeholder'] . '" cols="5" rows="2">' . esc_textarea(self::get_value($args['name'])) . '</textarea> </p>' . $after; break; //Adds a drop down custom type //Adds a drop down custom type case "select": $field = '<p class="form-row ' . implode(' ', $args['class']) . '"> <label for="' . esc_attr($args['name']) . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label>'; $field .= '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($input_required) . '">'; foreach ($args['options'] as $value => $label) { $field .= '<option value="' . esc_attr($value) . '"'; if (self::get_value($args['name']) == $value) { $field .= ' selected="selected"'; } $field .= '>' . __($label, 'fflcommerce') . '</option>'; } $field .= '</select></p>' . $after; break; default: $field = '<p class="form-row ' . implode(' ', $args['class']) . '"> <label for="' . esc_attr($args['name']) . '" class="' . implode(' ', $args['label_class']) . '">' . $args['label'] . $required . '</label> <input type="' . $args['type'] . '" class="input-text' . esc_attr($input_required) . '" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" placeholder="' . $args['placeholder'] . '" value="' . self::get_value($args['name']) . '" /> </p>' . $after; break; } $field = apply_filters('fflcommerce_address_field_types', $field, $args); if ($args['return']) { return $field; } else { echo $field; return null; } }
function fflcommerce_pay_action() { if (!is_fflcommerce_single_page(FFLCOMMERCE_PAY)) { return; } if (isset($_GET['pay_for_order']) && isset($_GET['order']) && isset($_GET['order_id'])) { // Pay for existing order $order_key = urldecode($_GET['order']); $order_id = (int) $_GET['order_id']; $order = new fflcommerce_order($order_id); if ($order->id == $order_id && $order->order_key == $order_key && $order->status == 'pending') { // Set customer location to order location if ($order->billing_country) { fflcommerce_customer::set_country($order->billing_country); } if ($order->billing_state) { fflcommerce_customer::set_state($order->billing_state); } if ($order->billing_postcode) { fflcommerce_customer::set_postcode($order->billing_postcode); } // Pay form was posted - process payment if (isset($_POST['pay']) && fflcommerce::verify_nonce('pay')) { // Update payment method if ($order->order_total > 0) { $payment_method = fflcommerce_clean($_POST['payment_method']); $data = (array) maybe_unserialize(get_post_meta($order_id, 'order_data', true)); $data['payment_method'] = $payment_method; update_post_meta($order_id, 'order_data', $data); $available_gateways = fflcommerce_payment_gateways::get_available_payment_gateways(); $result = $available_gateways[$payment_method]->process_payment($order_id); // Redirect to success/confirmation/payment page if ($result['result'] == 'success') { wp_safe_redirect($result['redirect']); exit; } } else { // No payment was required for order $order->payment_complete(); // filter redirect page $checkout_redirect = apply_filters('fflcommerce_get_checkout_redirect_page_id', fflcommerce_get_page_id('thanks')); wp_safe_redirect(get_permalink($checkout_redirect)); exit; } } } elseif ($order->status != 'pending') { fflcommerce::add_error(__('Your order has already been paid for. Please contact us if you need assistance.', 'fflcommerce')); } else { fflcommerce::add_error(__('Invalid order.', 'fflcommerce')); } } else { // Pay for order after checkout step if (isset($_GET['order'])) { $order_id = $_GET['order']; } else { $order_id = 0; } if (isset($_GET['key'])) { $order_key = $_GET['key']; } else { $order_key = ''; } if ($order_id > 0) { $order = new fflcommerce_order($order_id); if ($order->order_key != $order_key || $order->status != 'pending') { wp_safe_redirect(apply_filters('fflcommerce_get_myaccount_page_id', get_permalink(fflcommerce_get_page_id('myaccount')))); exit; } } else { wp_safe_redirect(apply_filters('fflcommerce_get_myaccount_page_id', get_permalink(fflcommerce_get_page_id('myaccount')))); exit; } } }
function fflcommerce_eu_b2b_vat_message() { if (fflcommerce_countries::is_eu_country(fflcommerce_customer::get_country()) && FFLCommerce_Base::get_options()->get('fflcommerce_eu_vat_reduction_message') == 'yes') { echo '<div class="clear"></div><div class="payment_message">' . __('If you have entered an EU VAT Number, it will be looked up when you <strong>Place</strong> your Order and verified. At that time <strong><em>Only</em></strong>, will VAT then be removed from the final Order and totals adjusted. You may enter your EU VAT Number either with, or without, the 2 character EU country code in front.', 'fflcommerce') . '</div>'; } }
/** * Validate the checkout */ public function validate_checkout() { if (fflcommerce_cart::is_empty()) { fflcommerce::add_error(sprintf(__('Sorry, your session has expired. <a href="%s">Return to homepage →</a>', 'fflcommerce'), home_url())); } // Process Discount Codes if (!empty($_POST['coupon_code'])) { $coupon = sanitize_title($_POST['coupon_code']); fflcommerce_cart::add_discount($coupon); } foreach (fflcommerce_cart::get_coupons() as $coupon) { fflcommerce_cart::is_valid_coupon($coupon); } // Checkout fields $this->posted['shipping_method'] = ''; $this->posted['shipping_service'] = ''; if (isset($_POST['shipping_method'])) { $shipping_method = fflcommerce_clean($_POST['shipping_method']); $shipping_data = explode(':', $shipping_method); $this->posted['shipping_method'] = $shipping_data[0]; $this->posted['shipping_service'] = $shipping_data[1]; } $this->posted['shiptobilling'] = isset($_POST['shiptobilling']) ? fflcommerce_clean($_POST['shiptobilling']) : ''; $this->posted['payment_method'] = isset($_POST['payment_method']) ? fflcommerce_clean($_POST['payment_method']) : ''; $this->posted['order_comments'] = isset($_POST['order_comments']) ? fflcommerce_clean($_POST['order_comments']) : ''; $this->posted['terms'] = isset($_POST['terms']) ? fflcommerce_clean($_POST['terms']) : ''; $this->posted['create_account'] = isset($_POST['create_account']) ? fflcommerce_clean($_POST['create_account']) : ''; $this->posted['account_username'] = isset($_POST['account_username']) ? fflcommerce_clean($_POST['account_username']) : ''; $this->posted['account_password'] = isset($_POST['account_password']) ? fflcommerce_clean($_POST['account_password']) : ''; $this->posted['account_password_2'] = isset($_POST['account_password_2']) ? fflcommerce_clean($_POST['account_password_2']) : ''; if (fflcommerce_cart::get_total(false) == 0) { $this->posted['payment_method'] = 'no_payment'; } // establish customer billing and shipping locations if (fflcommerce_cart::ship_to_billing_address_only()) { $this->posted['shiptobilling'] = 'true'; } $country = isset($_POST['billing_country']) ? fflcommerce_clean($_POST['billing_country']) : ''; $state = isset($_POST['billing_state']) ? fflcommerce_clean($_POST['billing_state']) : ''; $allowed_countries = FFLCommerce_Base::get_options()->get('fflcommerce_allowed_countries'); if ($allowed_countries === 'specific') { $specific_countries = FFLCommerce_Base::get_options()->get('fflcommerce_specific_allowed_countries'); if (!in_array($country, $specific_countries)) { fflcommerce::add_error(__('Invalid billing country.', 'fflcommerce')); return; } } if (fflcommerce_countries::country_has_states($country)) { $states = fflcommerce_countries::get_states($country); if (!in_array($state, array_keys($states))) { fflcommerce::add_error(__('Invalid billing state.', 'fflcommerce')); return; } } $postcode = isset($_POST['billing_postcode']) ? fflcommerce_clean($_POST['billing_postcode']) : ''; $ship_to_billing = FFLCommerce_Base::get_options()->get('fflcommerce_ship_to_billing_address_only') == 'yes'; fflcommerce_customer::set_location($country, $state, $postcode); if (FFLCommerce_Base::get_options()->get('fflcommerce_calc_shipping') == 'yes') { if ($ship_to_billing || !empty($_POST['shiptobilling'])) { fflcommerce_customer::set_shipping_location($country, $state, $postcode); } else { $country = isset($_POST['shipping_country']) ? fflcommerce_clean($_POST['shipping_country']) : ''; $state = isset($_POST['shipping_state']) ? fflcommerce_clean($_POST['shipping_state']) : ''; $postcode = isset($_POST['shipping_postcode']) ? fflcommerce_clean($_POST['shipping_postcode']) : ''; if ($allowed_countries === 'specific') { $specific_countries = FFLCommerce_Base::get_options()->get('fflcommerce_specific_allowed_countries'); if (!in_array($country, $specific_countries)) { fflcommerce::add_error(__('Invalid shipping country.', 'fflcommerce')); return; } } if (fflcommerce_countries::country_has_states($country)) { $states = fflcommerce_countries::get_states($country); if (!in_array($state, array_keys($states))) { fflcommerce::add_error(__('Invalid shipping state.', 'fflcommerce')); return; } } fflcommerce_customer::set_shipping_location($country, $state, $postcode); } } // Billing Information foreach ($this->billing_fields as $field) { $field = apply_filters('fflcommerce_billing_field', $field); $this->posted[$field['name']] = isset($_POST[$field['name']]) ? fflcommerce_clean($_POST[$field['name']]) : ''; // Format if (isset($field['format'])) { switch ($field['format']) { case 'postcode': $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']])); break; } } // Required if ($field['name'] == 'billing_state' && fflcommerce_customer::has_valid_shipping_state()) { $field['required'] = false; } if (isset($field['required']) && $field['required'] && empty($this->posted[$field['name']])) { fflcommerce::add_error($field['label'] . __(' (billing) is a required field.', 'fflcommerce')); } if ($field['name'] == 'billing_euvatno') { $vatno = isset($this->posted['billing_euvatno']) ? $this->posted['billing_euvatno'] : ''; $vatno = str_replace(' ', '', $vatno); $country = fflcommerce_tax::get_customer_country(); // strip any country code from the beginning of the number if (strpos($vatno, $country) === 0) { $vatno = substr($vatno, strlen($country)); } if ($vatno != '') { $url = 'http://isvat.appspot.com/' . $country . '/' . $vatno . '/'; $httpRequest = curl_init(); curl_setopt($httpRequest, CURLOPT_FAILONERROR, true); curl_setopt($httpRequest, CURLOPT_RETURNTRANSFER, true); curl_setopt($httpRequest, CURLOPT_HEADER, false); curl_setopt($httpRequest, CURLOPT_URL, $url); $result = curl_exec($httpRequest); curl_close($httpRequest); if ($result === 'false') { fflcommerce_log('EU VAT validation error with URL: ' . $url); fflcommerce::add_error($field['label'] . __(' (billing) is not a valid VAT Number. Leave it blank to disable VAT validation. (VAT may be charged depending on your location)', 'fflcommerce')); } else { $this->valid_euvatno = fflcommerce_countries::get_base_country() != fflcommerce_tax::get_customer_country() && fflcommerce_countries::is_eu_country(fflcommerce_tax::get_customer_country()); } } } // Validation if (isset($field['validate']) && !empty($this->posted[$field['name']])) { switch ($field['validate']) { case 'phone': if (!fflcommerce_validation::is_phone($this->posted[$field['name']])) { fflcommerce::add_error($field['label'] . __(' (billing) is not a valid number.', 'fflcommerce')); } break; case 'email': if (!fflcommerce_validation::is_email($this->posted[$field['name']])) { fflcommerce::add_error($field['label'] . __(' (billing) is not a valid email address.', 'fflcommerce')); } break; case 'postcode': if (!fflcommerce_validation::is_postcode($this->posted[$field['name']], $_POST['billing_country'])) { fflcommerce::add_error($field['label'] . __(' (billing) is not a valid postcode/ZIP.', 'fflcommerce')); } else { $this->posted[$field['name']] = fflcommerce_validation::format_postcode($this->posted[$field['name']], $_POST['billing_country']); } break; } } } // Shipping Information if (fflcommerce_shipping::is_enabled() && !fflcommerce_cart::ship_to_billing_address_only() && empty($this->posted['shiptobilling'])) { foreach ($this->shipping_fields as $field) { $field = apply_filters('fflcommerce_shipping_field', $field); if (isset($_POST[$field['name']])) { $this->posted[$field['name']] = fflcommerce_clean($_POST[$field['name']]); } else { $this->posted[$field['name']] = ''; } // Format if (isset($field['format'])) { switch ($field['format']) { case 'postcode': $this->posted[$field['name']] = strtolower(str_replace(' ', '', $this->posted[$field['name']])); break; } } // Required if ($field['name'] == 'shipping_state' && fflcommerce_customer::has_valid_shipping_state()) { $field['required'] = false; } if (isset($field['required']) && $field['required'] && empty($this->posted[$field['name']])) { fflcommerce::add_error($field['label'] . __(' (shipping) is a required field.', 'fflcommerce')); } // Validation if (isset($field['validate']) && !empty($this->posted[$field['name']])) { switch ($field['validate']) { case 'postcode': if (!fflcommerce_validation::is_postcode($this->posted[$field['name']], $country)) { fflcommerce::add_error($field['label'] . __(' (shipping) is not a valid postcode/ZIP.', 'fflcommerce')); } else { $this->posted[$field['name']] = fflcommerce_validation::format_postcode($this->posted[$field['name']], $country); } break; } } } } if ($this->must_register && empty($this->posted['create_account'])) { fflcommerce::add_error(__('Sorry, you must agree to creating an account', 'fflcommerce')); } if ($this->must_register || empty($user_id) && $this->posted['create_account']) { if (!$this->show_signup) { fflcommerce::add_error(__('Sorry, the shop owner has disabled guest purchases.', 'fflcommerce')); } if (empty($this->posted['account_username'])) { fflcommerce::add_error(__('Please enter an account username.', 'fflcommerce')); } if (empty($this->posted['account_password'])) { fflcommerce::add_error(__('Please enter an account password.', 'fflcommerce')); } if ($this->posted['account_password_2'] !== $this->posted['account_password']) { fflcommerce::add_error(__('Passwords do not match.', 'fflcommerce')); } // Check the username if (!validate_username($this->posted['account_username'])) { fflcommerce::add_error(__('Invalid email/username.', 'fflcommerce')); } elseif (username_exists($this->posted['account_username'])) { fflcommerce::add_error(__('An account is already registered with that username. Please choose another.', 'fflcommerce')); } // Check the e-mail address if (email_exists($this->posted['billing_email'])) { fflcommerce::add_error(__('An account is already registered with your email address. Please login.', 'fflcommerce')); } } // Terms if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && fflcommerce_get_page_id('terms') > 0) { fflcommerce::add_error(__('You must accept our Terms & Conditions.', 'fflcommerce')); } if (fflcommerce_cart::needs_shipping()) { // Shipping Method $available_methods = fflcommerce_shipping::get_available_shipping_methods(); if (!isset($available_methods[$this->posted['shipping_method']])) { fflcommerce::add_error(__('Invalid shipping method.', 'fflcommerce')); } } }
/** * @var $available_methods array List of available shipping methods. */ ?> <?php $available_methods = fflcommerce_shipping::get_available_shipping_methods(); ?> <tr> <td colspan="2"><?php _e('Shipping', 'fflcommerce'); ?> <br /> <small><?php echo _x('To: ', 'shipping destination', 'fflcommerce') . __(fflcommerce_customer::get_shipping_country_or_state(), 'fflcommerce'); ?> </small> </td> <td> <?php if (count($available_methods) > 0) { ?> <select name="shipping_method" id="shipping_method"> <?php foreach ($available_methods as $method) { /** @var fflcommerce_shipping_method $method */ ?> <?php for ($i = 0; $i < $method->get_rates_amount(); $i++) { $service = $method->get_selected_service($i);
* @var $recent_orders int Number of recent orders to show. */ fflcommerce::show_messages(); if (is_user_logged_in()) { ?> <p><?php echo sprintf(__('Hello, <strong>%s</strong>. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">change your password</a>.', 'fflcommerce'), $current_user->display_name, apply_filters('fflcommerce_get_change_password_page_id', get_permalink(fflcommerce_get_page_id('change_password')))); ?> </p> <?php do_action('fflcommerce_before_my_account'); ?> <?php if ($downloads = fflcommerce_customer::get_downloadable_products()) { ?> <h2><?php _e('Available downloads', 'fflcommerce'); ?> </h2> <ul class="digital-downloads"> <?php foreach ($downloads as $download) { ?> <li><?php if (is_numeric($download['downloads_remaining'])) { ?> <span class="count"><?php echo $download['downloads_remaining'] . _n(' download Remaining', ' downloads Remaining', 'fflcommerce'); ?>
<div class="payment_box payment_method_<?php echo esc_attr($gateway->id); ?> " style="display:none;"><?php $gateway->payment_fields(); ?> </div> <?php } ?> </li> <?php } } } else { if (!fflcommerce_customer::get_country()) { echo '<p>' . __('Please fill in your details above to see available payment methods.', 'fflcommerce') . '</p>'; } else { echo '<p>' . __('Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'fflcommerce') . '</p>'; } } ?> </ul> <div class="form-row"> <noscript> <?php _e('Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'fflcommerce'); ?> <br /><input type="submit" class="button-alt" name="update_totals" value="<?php _e('Update totals', 'fflcommerce'); ?>
public static function get_cart_shipping_total($for_display = true, $order_exclude_tax = false) { /* Quit early if there is no shipping label. */ if (!fflcommerce_shipping::get_label()) { return false; } // Do not display taxes if shipping country is not set if (fflcommerce_customer::get_shipping_country() == '') { return false; } /* Shipping price is 0.00. */ if (fflcommerce_shipping::get_total() <= 0) { return $for_display ? __('Free!', 'fflcommerce') : 0; } /* Not calculating taxes. */ if (self::get_options()->get('fflcommerce_calc_taxes') == 'no') { return $for_display ? fflcommerce_price(self::$shipping_total) : number_format(self::$shipping_total, 2, '.', ''); } if (self::get_options()->get('fflcommerce_prices_include_tax') == 'no' || $order_exclude_tax) { $return = $for_display ? fflcommerce_price(self::$shipping_total) : number_format(self::$shipping_total, 2, '.', ''); if (self::$shipping_tax_total > 0 && $for_display) { $return .= ' <small>' . __('(ex. tax)', 'fflcommerce') . '</small>'; } } else { $return = $for_display ? fflcommerce_price(self::$shipping_total + self::$shipping_tax_total) : number_format(self::$shipping_total + self::$shipping_tax_total, 2, '.', ''); if (self::$shipping_tax_total > 0 && $for_display) { $return .= ' <small>' . __('(inc. tax)', 'fflcommerce') . '</small>'; } } return $return; }
function fflcommerce_ajax_update_order_review() { check_ajax_referer('update-order-review', 'security'); if (!defined('FFLCOMMERCE_CHECKOUT')) { define('FFLCOMMERCE_CHECKOUT', true); } fflcommerce_cart::get_cart(); if (sizeof(fflcommerce_cart::$cart_contents) == 0) { echo '<p class="error">' . __('Sorry, your session has expired.', 'fflcommerce') . ' <a href="' . home_url() . '">' . __('Return to homepage →', 'fflcommerce') . '</a></p>'; exit; } do_action('fflcommerce_checkout_update_order_review', $_POST['post_data']); if (isset($_POST['shipping_method'])) { $shipping_method = explode(":", $_POST['shipping_method']); fflcommerce_session::instance()->chosen_shipping_method_id = $shipping_method[0]; if (is_numeric($shipping_method[2])) { fflcommerce_session::instance()->selected_rate_id = $shipping_method[2]; } } if (!empty($_POST['coupon_code'])) { fflcommerce_cart::add_discount(sanitize_title($_POST['coupon_code'])); fflcommerce::show_messages(); } if (isset($_POST['country'])) { fflcommerce_customer::set_country($_POST['country']); } if (isset($_POST['state'])) { fflcommerce_customer::set_state($_POST['state']); } if (isset($_POST['postcode'])) { fflcommerce_customer::set_postcode($_POST['postcode']); } if (isset($_POST['s_country'])) { fflcommerce_customer::set_shipping_country($_POST['s_country']); } if (isset($_POST['s_state'])) { fflcommerce_customer::set_shipping_state($_POST['s_state']); } if (isset($_POST['s_postcode'])) { fflcommerce_customer::set_shipping_postcode($_POST['s_postcode']); } fflcommerce_cart::calculate_totals(); do_action('fflcommerce_checkout_order_review'); die; }
function fflcommerce_frontend_scripts() { $options = FFLCommerce_Base::get_options(); $frontend_css = FFLCOMMERCE_URL . '/assets/css/frontend.css'; $theme_css = file_exists(get_stylesheet_directory() . '/fflcommerce/style.css') ? get_stylesheet_directory_uri() . '/fflcommerce/style.css' : $frontend_css; if ($options->get('fflcommerce_disable_css') == 'no') { if ($options->get('fflcommerce_frontend_with_theme_css') == 'yes' && $frontend_css != $theme_css) { jrto_enqueue_style('frontend', 'fflcommerce_theme_styles', $frontend_css); } jrto_enqueue_style('frontend', 'fflcommerce_styles', $theme_css); } wp_enqueue_script('jquery'); wp_register_script('jquery-blockui', '//cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.66.0-2013.10.09/jquery.blockUI.min.js', array('jquery'), '2.66.0'); wp_enqueue_script('jquery-blockui'); jrto_enqueue_script('frontend', 'fflcommerce_global', FFLCOMMERCE_URL . '/assets/js/global.js', array('jquery'), array('in_footer' => true)); if ($options->get('fflcommerce_disable_fancybox') == 'no') { jrto_enqueue_script('frontend', 'prettyPhoto', FFLCOMMERCE_URL . '/assets/js/jquery.prettyPhoto.js', array('jquery'), array('in_footer' => true)); jrto_enqueue_style('frontend', 'prettyPhoto', FFLCOMMERCE_URL . '/assets/css/prettyPhoto.css'); } jrto_enqueue_script('frontend', 'fflcommerce-cart', FFLCOMMERCE_URL . '/assets/js/cart.js', array('jquery'), array('in_footer' => true, 'page' => FFLCOMMERCE_CART)); jrto_enqueue_script('frontend', 'fflcommerce-checkout', FFLCOMMERCE_URL . '/assets/js/checkout.js', array('jquery', 'jquery-blockui'), array('in_footer' => true, 'page' => array(FFLCOMMERCE_CHECKOUT, FFLCOMMERCE_PAY))); jrto_enqueue_script('frontend', 'fflcommerce-validation', FFLCOMMERCE_URL . '/assets/js/validation.js', array(), array('in_footer' => true, 'page' => FFLCOMMERCE_CHECKOUT)); jrto_enqueue_script('frontend', 'fflcommerce-payment', FFLCOMMERCE_URL . '/assets/js/pay.js', array('jquery'), array('page' => FFLCOMMERCE_PAY)); jrto_enqueue_script('frontend', 'fflcommerce-single-product', FFLCOMMERCE_URL . '/assets/js/single-product.js', array('jquery'), array('in_footer' => true, 'page' => FFLCOMMERCE_PRODUCT)); jrto_enqueue_script('frontend', 'fflcommerce-countries', FFLCOMMERCE_URL . '/assets/js/countries.js', array(), array('in_footer' => true, 'page' => array(FFLCOMMERCE_CHECKOUT, FFLCOMMERCE_CART, FFLCOMMERCE_EDIT_ADDRESS))); /* Script.js variables */ // TODO: clean this up, a lot aren't even used anymore, do away with it $fflcommerce_params = array('ajax_url' => admin_url('admin-ajax.php', 'fflcommerce'), 'assets_url' => FFLCOMMERCE_URL, 'validate_postcode' => $options->get('fflcommerce_enable_postcode_validating', 'no'), 'checkout_url' => admin_url('admin-ajax.php?action=fflcommerce-checkout', 'fflcommerce'), 'currency_symbol' => get_fflcommerce_currency_symbol(), 'get_variation_nonce' => wp_create_nonce("get-variation"), 'load_fancybox' => $options->get('fflcommerce_disable_fancybox') == 'no', 'option_guest_checkout' => $options->get('fflcommerce_enable_guest_checkout'), 'select_state_text' => __('Select a state…', 'fflcommerce'), 'state_text' => __('state', 'fflcommerce'), 'ratings_message' => __('Please select a star to rate your review.', 'fflcommerce'), 'update_order_review_nonce' => wp_create_nonce("update-order-review"), 'billing_state' => fflcommerce_customer::get_state(), 'shipping_state' => fflcommerce_customer::get_shipping_state(), 'is_checkout' => is_page(fflcommerce_get_page_id('checkout')) || is_page(fflcommerce_get_page_id('pay')), 'error_hide_time' => FFLCommerce_Base::get_options()->get('fflcommerce_error_disappear_time', 8000), 'message_hide_time' => FFLCommerce_Base::get_options()->get('fflcommerce_message_disappear_time', 4000)); if (isset(fflcommerce_session::instance()->min_price)) { $fflcommerce_params['min_price'] = $_GET['min_price']; } if (isset(fflcommerce_session::instance()->max_price)) { $fflcommerce_params['max_price'] = $_GET['max_price']; } $fflcommerce_params = apply_filters('fflcommerce_params', $fflcommerce_params); jrto_localize_script('fflcommerce_global', 'fflcommerce_params', $fflcommerce_params); }
?> <?php } else { ?> <?php _e('Shipping Address', 'fflcommerce'); ?> <?php } ?> </h3> <?php foreach ($address as $field) { ?> <?php fflcommerce_customer::address_form_field($field); ?> <?php } ?> <?php fflcommerce::nonce_field('edit_address'); ?> <input type="submit" class="button" name="save_address" value="<?php _e('Save Address', 'fflcommerce'); ?> " /> <a class="button-alt" href="<?php echo $account_url; ?> "><?php