function fflcommerce_admin_user_profile(WP_User $user)
{
    $customer = new fflcommerce_user($user->ID);
    wp_enqueue_script('admin', 'fflcommerce-select2', FFLCOMMERCE_URL . '/assets/js/select2.min.js', array('jquery'));
    wp_enqueue_style('admin', 'fflcommerce-select2', FFLCOMMERCE_URL . '/assets/css/select2.css');
    fflcommerce_render('admin/user-profile', array('user' => $user, 'customer' => $customer));
}
Esempio n. 2
0
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()));
}
Esempio n. 3
0
function fflcommerce_view_order()
{
    $options = FFLCommerce_Base::get_options();
    $order = new fflcommerce_order($_GET['order']);
    fflcommerce_render('shortcode/my_account/view_order', array('order' => $order, 'options' => $options));
}
Esempio n. 4
0
?>
</th>
		<td><input type="text" name="fflcommerce[shipping_city]" value="<?php 
echo $customer->getShippingCity();
?>
" class="regular-text" /> </td>
	</tr>
	<tr>
		<th scope="row"><?php 
_e('Postcode', 'fflcommerce');
?>
</th>
		<td><input type="text" name="fflcommerce[shipping_postcode]" value="<?php 
echo $customer->getShippingPostcode();
?>
" class="regular-text" /> </td>
	</tr>
	<tr>
		<th scope="row"><?php 
_e('Country', 'fflcommerce');
?>
</th>
		<td><?php 
fflcommerce_render('admin/user-profile/country_dropdown', array('country' => $customer->getShippingCountry(), 'state' => $customer->getShippingState(), 'name' => 'shipping_country'));
?>
</td>
	</tr>
	</tbody>
</table>
<span style="clear: both; display: block;"></span>
Esempio n. 5
0
/**
 * Helper function to locate proper template and set up environment based on passed array.
 * Returns value of rendered template as a string.
 *
 * @param string $template Template name.
 * @param array $variables Template variables
 * @return string
 */
function fflcommerce_render_result($template, array $variables)
{
    ob_start();
    fflcommerce_render($template, $variables);
    return ob_get_clean();
}