Skip to content

Commit

Permalink
Replaced → / ← on frontend with icons from our font. closes w…
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskoster committed Oct 28, 2013
1 parent 8ebd753 commit 1fbb624
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 47 deletions.
2 changes: 1 addition & 1 deletion assets/css/woocommerce.css

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion assets/css/woocommerce.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,24 @@ p.demo_store {
}
}

.woocommerce, .woocommerce-page { // namespace to avoid conflict with common global class names
/* =Utilities
-------------------------------------------------------------- */
.wc-forward, .wc-forward a {
&:after {
.iconafter( "\e029" );
font-size:.75em;
}
}
.wc-backward, .wc-backward a {
&:before {
.iconbefore( "\e02f" );
font-size:.75em;
}
}

/* =Main Styles (namespace to avoid conflict with common global class names)
-------------------------------------------------------------- */
.woocommerce, .woocommerce-page {

.woocommerce-message, .woocommerce-error, .woocommerce-info {
padding: 1em 1em 1em 3.5em !important;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/frontend/add-to-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jQuery(document).ready(function($) {

// View cart text
if ( ! wc_add_to_cart_params.is_cart && $thisbutton.parent().find('.added_to_cart').size() == 0 )
$thisbutton.after( ' <a href="' + wc_add_to_cart_params.cart_url + '" class="added_to_cart" title="' + wc_add_to_cart_params.i18n_view_cart + '">' + wc_add_to_cart_params.i18n_view_cart + '</a>' );
$thisbutton.after( ' <a href="' + wc_add_to_cart_params.cart_url + '" class="added_to_cart wc-forward" title="' + wc_add_to_cart_params.i18n_view_cart + '">' + wc_add_to_cart_params.i18n_view_cart + '</a>' );

// Replace fragments
if ( fragments ) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/frontend/add-to-cart.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 31 additions & 31 deletions includes/class-wc-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function get_cart_from_session() {
'coupon_discount_amounts' => array(),
);

foreach ( $this->cart_session_data as $key => $default )
foreach ( $this->cart_session_data as $key => $default )
$this->$key = WC()->session->get( $key, $default );

// Load coupons
Expand Down Expand Up @@ -195,7 +195,7 @@ public function set_session() {
WC()->session->set( 'applied_coupons', $this->applied_coupons );
WC()->session->set( 'coupon_discount_amounts', $this->coupon_discount_amounts );

foreach ( $this->cart_session_data as $key => $default )
foreach ( $this->cart_session_data as $key => $default )
WC()->session->set( $key, $this->$key );

if ( get_current_user_id() )
Expand Down Expand Up @@ -565,7 +565,7 @@ public function get_cross_sells() {
*/
public function get_cart_url() {
$cart_page_id = woocommerce_get_page_id('cart');
if ( $cart_page_id )
if ( $cart_page_id )
return apply_filters( 'woocommerce_get_cart_url', get_permalink( $cart_page_id ) );
}

Expand Down Expand Up @@ -640,7 +640,7 @@ public function get_tax_totals() {
$tax_totals[ $code ] = new stdClass();
$tax_totals[ $code ]->amount = 0;
}

$tax_totals[ $code ]->tax_rate_id = $key;
$tax_totals[ $code ]->is_compound = $this->tax->is_compound( $key );
$tax_totals[ $code ]->label = $this->tax->get_rate_label( $key );
Expand Down Expand Up @@ -683,7 +683,7 @@ public function find_product_in_cart( $cart_id = false ) {
public function generate_cart_id( $product_id, $variation_id = '', $variation = '', $cart_item_data = array() ) {
$id_parts = array( $product_id );

if ( $variation_id )
if ( $variation_id )
$id_parts[] = $variation_id;

if ( is_array( $variation ) ) {
Expand Down Expand Up @@ -763,7 +763,7 @@ public function add_to_cart( $product_id, $quantity = 1, $variation_id = '', $va

// If its greater than 0, its already in the cart
if ( $in_cart_quantity > 0 ) {
wc_add_error( sprintf( '<a href="%s" class="button">%s</a> %s', get_permalink( woocommerce_get_page_id( 'cart' ) ), __( 'View Cart &rarr;', 'woocommerce' ), sprintf( __( 'You cannot add another &quot;%s&quot; to your cart.', 'woocommerce' ), $product_data->get_title() ) ) );
wc_add_error( sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', get_permalink( woocommerce_get_page_id( 'cart' ) ), __( 'View Cart', 'woocommerce' ), sprintf( __( 'You cannot add another &quot;%s&quot; to your cart.', 'woocommerce' ), $product_data->get_title() ) ) );
return false;
}
}
Expand All @@ -777,15 +777,15 @@ public function add_to_cart( $product_id, $quantity = 1, $variation_id = '', $va
if ( $variation_id && $product_data->variation_has_stock ) {

if ( isset( $product_qty_in_cart[ $variation_id ] ) && ! $product_data->has_enough_stock( $product_qty_in_cart[ $variation_id ] + $quantity ) ) {
wc_add_error( sprintf(__( '<a href="%s" class="button">%s</a> You cannot add that amount to the cart &mdash; we have %s in stock and you already have %s in your cart.', 'woocommerce' ), get_permalink( woocommerce_get_page_id( 'cart' ) ), __( 'View Cart &rarr;', 'woocommerce' ), $product_data->get_stock_quantity(), $product_qty_in_cart[ $variation_id ] ));
wc_add_error( sprintf(__( '<a href="%s" class="button wc-forward">%s</a> You cannot add that amount to the cart &mdash; we have %s in stock and you already have %s in your cart.', 'woocommerce' ), get_permalink( woocommerce_get_page_id( 'cart' ) ), __( 'View Cart', 'woocommerce' ), $product_data->get_stock_quantity(), $product_qty_in_cart[ $variation_id ] ));
return false;
}

// Products
} else {

if ( isset( $product_qty_in_cart[ $product_id ] ) && ! $product_data->has_enough_stock( $product_qty_in_cart[ $product_id ] + $quantity ) ) {
wc_add_error( sprintf(__( '<a href="%s" class="button">%s</a> You cannot add that amount to the cart &mdash; we have %s in stock and you already have %s in your cart.', 'woocommerce' ), get_permalink( woocommerce_get_page_id( 'cart' ) ), __( 'View Cart &rarr;', 'woocommerce' ), $product_data->get_stock_quantity(), $product_qty_in_cart[ $product_id ] ));
wc_add_error( sprintf(__( '<a href="%s" class="button wc-forward">%s</a> You cannot add that amount to the cart &mdash; we have %s in stock and you already have %s in your cart.', 'woocommerce' ), get_permalink( woocommerce_get_page_id( 'cart' ) ), __( 'View Cart', 'woocommerce' ), $product_data->get_stock_quantity(), $product_qty_in_cart[ $product_id ] ));
return false;
}

Expand Down Expand Up @@ -936,7 +936,7 @@ public function calculate_totals() {
* e.g. $100 bike with $10 coupon = customer pays $90 and tax worked backwards from that
*/
} elseif ( $this->prices_include_tax ) {

// Get base tax rates
if ( empty( $shop_tax_rates[ $_product->tax_class ] ) )
$shop_tax_rates[ $_product->tax_class ] = $this->tax->get_shop_base_rate( $_product->tax_class );
Expand All @@ -955,10 +955,10 @@ public function calculate_totals() {

// Work out a new base price without the shop's base tax
$taxes = $this->tax->calc_tax( $line_price, $base_tax_rates, true, true );

// Now we have a new item price (excluding TAX)
$line_subtotal = $line_price - array_sum( $taxes );

// Now add modifed taxes
$tax_result = $this->tax->calc_tax( $line_subtotal, $item_tax_rates );
$line_subtotal_tax = array_sum( $taxes );
Expand All @@ -980,7 +980,7 @@ public function calculate_totals() {
* This calculation is simpler - work with the base, untaxed price.
*/
} else {

// Get item tax rates
if ( empty( $tax_rates[ $_product->get_tax_class() ] ) )
$tax_rates[ $_product->get_tax_class() ] = $this->tax->get_rates( $_product->get_tax_class() );
Expand Down Expand Up @@ -1027,7 +1027,7 @@ public function calculate_totals() {
* Prices include tax
*/
} elseif ( $this->prices_include_tax ) {

$base_tax_rates = $shop_tax_rates[ $_product->tax_class ];
$item_tax_rates = $tax_rates[ $_product->get_tax_class() ];

Expand All @@ -1038,17 +1038,17 @@ public function calculate_totals() {

// Work out a new base price without the shop's base tax
$taxes = $this->tax->calc_tax( $line_price, $base_tax_rates, true, true );

// Now we have a new item price (excluding TAX)
$line_subtotal = $line_price - array_sum( $taxes );

// Now add modifed taxes
$taxes = $this->tax->calc_tax( $line_subtotal, $item_tax_rates );
$line_subtotal_tax = array_sum( $taxes );

// Adjusted price (this is the price including the new tax rate)
$adjusted_price = ( $line_subtotal + $line_subtotal_tax ) / $values['quantity'];

// Apply discounts
$discounted_price = $this->get_discounted_price( $values, $adjusted_price, true );
$discounted_taxes = $this->tax->calc_tax( $discounted_price * $values['quantity'], $item_tax_rates, true );
Expand All @@ -1062,7 +1062,7 @@ public function calculate_totals() {

// Work out a new base price without the shop's base tax
$taxes = $this->tax->calc_tax( $line_price, $item_tax_rates, true );

// Now we have a new item price (excluding TAX)
$line_subtotal = $line_price - array_sum( $taxes );
$line_subtotal_tax = array_sum( $taxes );
Expand All @@ -1083,16 +1083,16 @@ public function calculate_totals() {
* Prices exclude tax
*/
} else {

$item_tax_rates = $tax_rates[ $_product->get_tax_class() ];

// Work out a new base price without the shop's base tax
$taxes = $this->tax->calc_tax( $line_price, $item_tax_rates );

// Now we have a new item price (excluding TAX)
$line_subtotal = $line_price - array_sum( $taxes );
$line_subtotal_tax = array_sum( $taxes );

// Now calc product rates
$discounted_price = $this->get_discounted_price( $values, $base_price, true );
$discounted_taxes = $this->tax->calc_tax( $discounted_price * $values['quantity'], $item_tax_rates );
Expand Down Expand Up @@ -1240,7 +1240,7 @@ public function get_shipping_packages() {

$packages[0]['contents'] = $this->get_cart(); // Items in the package
$packages[0]['contents_cost'] = 0; // Cost of items in the package, set below
$packages[0]['applied_coupons'] = $this->applied_coupons;
$packages[0]['applied_coupons'] = $this->applied_coupons;
$packages[0]['destination']['country'] = WC()->customer->get_shipping_country();
$packages[0]['destination']['state'] = WC()->customer->get_shipping_state();
$packages[0]['destination']['postcode'] = WC()->customer->get_shipping_postcode();
Expand Down Expand Up @@ -1564,7 +1564,7 @@ public function remove_coupons( $type = null ) {
foreach ( $this->applied_coupons as $code ) {
$coupon = new WC_Coupon( $code );

if ( $coupon->apply_before_tax() )
if ( $coupon->apply_before_tax() )
$this->remove_coupon( $code );
}
}
Expand All @@ -1573,7 +1573,7 @@ public function remove_coupons( $type = null ) {
foreach ( $this->applied_coupons as $code ) {
$coupon = new WC_Coupon( $code );

if ( ! $coupon->apply_before_tax() )
if ( ! $coupon->apply_before_tax() )
$this->remove_coupon( $code );
}
}
Expand All @@ -1596,8 +1596,8 @@ public function remove_coupon( $coupon_code ) {
// Get the coupon
$coupon_code = apply_filters( 'woocommerce_coupon_code', $coupon_code );
$position = array_search( $coupon_code, $this->applied_coupons );
if ( $position !== false )

if ( $position !== false )
unset( $this->applied_coupons[ $position ] );

WC()->session->set( 'applied_coupons', $this->applied_coupons );
Expand All @@ -1613,7 +1613,7 @@ public function remove_coupon( $coupon_code ) {
* @return float price
*/
public function get_discounted_price( $values, $price, $add_totals = false ) {
if ( ! $price )
if ( ! $price )
return $price;

if ( ! empty( $this->applied_coupons ) ) {
Expand All @@ -1622,10 +1622,10 @@ public function get_discounted_price( $values, $price, $add_totals = false ) {

if ( $coupon->apply_before_tax() && $coupon->is_valid() ) {
if ( $coupon->is_valid_for_product( $values['data'] ) || $coupon->is_valid_for_cart() ) {

$discount_amount = $coupon->get_discount_amount( $price, $values, $single = true );
$price = max( $price - $discount_amount, 0 );

if ( $add_totals ) {
$this->discount_cart += $discount_amount * $values['quantity'];
$this->increase_coupon_discount_amount( $code, $discount_amount * $values['quantity'] );
Expand Down Expand Up @@ -1815,7 +1815,7 @@ public function get_total() {
*/
public function get_total_ex_tax() {
$total = $this->total - $this->tax_total - $this->shipping_tax_total;
if ( $total < 0 )
if ( $total < 0 )
$total = 0;
return apply_filters( 'woocommerce_cart_total_ex_tax', woocommerce_price( $total ) );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public function process_checkout() {
do_action( 'woocommerce_before_checkout_process' );

if ( sizeof( WC()->cart->get_cart() ) == 0 )
wc_add_error( sprintf( __( 'Sorry, your session has expired. <a href="%s">Return to homepage &rarr;</a>', 'woocommerce' ), home_url() ) );
wc_add_error( sprintf( __( 'Sorry, your session has expired. <a href="%s" class="wc-backward">Return to homepage</a>', 'woocommerce' ), home_url() ) );

do_action( 'woocommerce_checkout_process' );

Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-frontend-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function load_scripts() {
wp_localize_script( 'wc-add-to-cart', 'wc_add_to_cart_params', apply_filters( 'wc_add_to_cart_params', array(
'ajax_url' => WC()->ajax_url(),
'ajax_loader_url' => apply_filters( 'woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
'i18n_view_cart' => esc_attr__( 'View Cart &rarr;', 'woocommerce' ),
'i18n_view_cart' => esc_attr__( 'View Cart', 'woocommerce' ),
'cart_url' => get_permalink( woocommerce_get_page_id( 'cart' ) ),
'is_cart' => is_cart(),
'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' )
Expand Down
2 changes: 1 addition & 1 deletion includes/shortcodes/class-wc-shortcode-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static function order_pay( $order_id ) {
$valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order );

if ( ! current_user_can( 'pay_for_order', $order_id ) ) {
echo '<div class="woocommerce-error">' . __( 'Invalid order.', 'woocommerce' ) . ' <a href="' . get_permalink( woocommerce_get_page_id( 'myaccount' ) ).'">'. __( 'My Account &rarr;', 'woocommerce' ) .'</a>' . '</div>';
echo '<div class="woocommerce-error">' . __( 'Invalid order.', 'woocommerce' ) . ' <a href="' . get_permalink( woocommerce_get_page_id( 'myaccount' ) ) . '" class="wc-forward">' . __( 'My Account', 'woocommerce' ) . '</a>' . '</div>';
return;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/shortcodes/class-wc-shortcode-view-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function output( $atts ) {
}

if ( !current_user_can( 'view_order', $order_id ) ) {
echo '<div class="woocommerce-error">' . __( 'Invalid order.', 'woocommerce' ) . ' <a href="'.get_permalink( woocommerce_get_page_id('myaccount') ).'">'. __( 'My Account &rarr;', 'woocommerce' ) .'</a>' . '</div>';
echo '<div class="woocommerce-error">' . __( 'Invalid order.', 'woocommerce' ) . ' <a href="' . get_permalink( woocommerce_get_page_id( 'myaccount' ) ) . '" class="wc-forward">' . __( 'My Account', 'woocommerce' ) . '</a>' . '</div>';
return;
}

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Tweak - Coupon in admin bar new menu #3974
* Tweak - Shortcode tag filters + updated menu names to make white labelling easier.
* Tweak - Removed placeholder polyfill. Use this plugin to replace functionality if required: http://wordpress.org/plugins/html5-placeholder-polyfill/
* Tweak - Replaced all instances of &rarr; and &larr; in frontent using wc icon font plus .wc-forward and .wc-backward utility classes.
* Fix - Changed MyException to Exception in Checkout class as MyException class does not exist in WooCommerce
* Fix - Default cart widget styling on non-wc pages.
* Fix - Rounding for mijireh tax ex. price.
Expand Down
Loading

0 comments on commit 1fbb624

Please sign in to comment.