'',
'wrap_before' => '
',
'wrap_after' => '
',
'before' => '',
'after' => '',
'home' => _x('Home', 'breadcrumb', 'ariel'),
);
}
#Woocommerce Loop Hooks
remove_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10);
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 10);
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
remove_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
remove_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10);
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
remove_action('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10);
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
add_action('woocommerce_before_shop_loop_item', 'woocommerce_show_product_loop_sale_flash', 10);
add_action('woocommerce_before_shop_loop_item', 'ariel_template_loop_product_thumb', 10);
add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10);
add_action('woocommerce_before_shop_loop_item_title', 'ariel_template_loop_product_thumb_close', 10);
add_action('woocommerce_shop_loop_item_title', 'ariel_template_loop_product_title', 10);
add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
add_filter( 'woocommerce_pagination_args', 'ariel_woo_pagination' );
#Woocommerce Single Product Hooks
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 1 );
add_filter( 'comment_form_submit_field', 'ariel_product_review_submit_button', 10, 2 );
#Insert the opening tag for product-thumb class in the loop.
function ariel_template_loop_product_thumb()
{
$output = '\n";
}
#Show the product title in the product loop. By default this is an H2.
function ariel_template_loop_product_title()
{
echo '';
}
/**
* Get the product thumbnail, or the placeholder if not set.
*
* @subpackage Loop
* @param string $size (default: 'shop_catalog')
* @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0)
* @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0)
* @return string
*/
function woocommerce_get_product_thumbnail( $size = 'ariel-shop', $deprecated1 = 0, $deprecated2 = 0 ) {
global $post;
if ( has_post_thumbnail() ) {
$props = wc_get_product_attachment_props( get_post_thumbnail_id(), $post );
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size );
$image = $image[0];
return '
';
} elseif ( wc_placeholder_img_src() ) {
return '
';
}
}
/**
* Outputs a checkout/address form field.
*
* @subpackage Forms
* @param string $key
* @param mixed $args
* @param string $value (default: null)
*/
function woocommerce_form_field( $key, $args, $value = null ) {
$defaults = array(
'type' => 'text',
'label' => '',
'description' => '',
'placeholder' => '',
'maxlength' => false,
'required' => false,
'autocomplete' => false,
'id' => $key,
'class' => array(),
'label_class' => array(),
'input_class' => array(),
'return' => false,
'options' => array(),
'custom_attributes' => array(),
'validate' => array(),
'default' => '',
'autofocus' => '',
'priority' => '',
);
$args = wp_parse_args( $args, $defaults );
$args = apply_filters( 'woocommerce_form_field_args', $args, $key, $value );
if ( $args['required'] ) {
$args['class'][] = 'validate-required';
//$required = ' *';
$required = ' *';
} else {
$required = '';
}
if ( is_string( $args['label_class'] ) ) {
$args['label_class'] = array( $args['label_class'] );
}
if ( is_null( $value ) ) {
$value = $args['default'];
}
// Custom attribute handling
$custom_attributes = array();
$args['custom_attributes'] = array_filter( (array) $args['custom_attributes'] );
if ( $args['maxlength'] ) {
$args['custom_attributes']['maxlength'] = absint( $args['maxlength'] );
}
if ( ! empty( $args['autocomplete'] ) ) {
$args['custom_attributes']['autocomplete'] = $args['autocomplete'];
}
if ( true === $args['autofocus'] ) {
$args['custom_attributes']['autofocus'] = 'autofocus';
}
if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
}
}
if ( ! empty( $args['validate'] ) ) {
foreach ( $args['validate'] as $validate ) {
$args['class'][] = 'validate-' . $validate;
}
}
$field = '';
$label_id = $args['id'];
$sort = $args['priority'] ? $args['priority'] : '';
$field_container = '%3$s
';
switch ( $args['type'] ) {
case 'country' :
$countries = 'shipping_country' === $key ? WC()->countries->get_shipping_countries() : WC()->countries->get_allowed_countries();
if ( 1 === sizeof( $countries ) ) {
$field .= '' . current( array_values( $countries ) ) . '';
$field .= '';
} else {
$field = '';
$field .= '';
}
break;
case 'state' :
/* Get Country */
$country_key = 'billing_state' === $key ? 'billing_country' : 'shipping_country';
$current_cc = WC()->checkout->get_value( $country_key );
$states = WC()->countries->get_states( $current_cc );
if ( is_array( $states ) && empty( $states ) ) {
$field_container = '%3$s
';
$field .= '';
} elseif ( ! is_null( $current_cc ) && is_array( $states ) ) {
$field .= '';
} else {
$field .= '';
}
break;
case 'textarea' :
$field .= '';
break;
case 'checkbox' :
$field = '';
break;
case 'password' :
case 'text' :
case 'email' :
case 'tel' :
case 'number' :
$field .= '';
break;
case 'select' :
$options = $field = '';
if ( ! empty( $args['options'] ) ) {
foreach ( $args['options'] as $option_key => $option_text ) {
if ( '' === $option_key ) {
// If we have a blank option, select2 needs a placeholder
if ( empty( $args['placeholder'] ) ) {
$args['placeholder'] = $option_text ? $option_text : __( 'Choose an option', 'ariel' );
}
$custom_attributes[] = 'data-allow_clear="true"';
}
$options .= '';
}
$field .= '';
}
break;
case 'radio' :
$label_id = current( array_keys( $args['options'] ) );
if ( ! empty( $args['options'] ) ) {
foreach ( $args['options'] as $option_key => $option_text ) {
$field .= '';
$field .= '';
}
}
break;
}
if ( ! empty( $field ) ) {
$field_html = '';
if ( $args['label'] && 'checkbox' != $args['type'] ) {
$field_html .= '';
}
$field_html .= $field;
if ( $args['description'] ) {
$field_html .= '' . esc_html( $args['description'] ) . '';
}
$container_class = esc_attr( implode( ' ', $args['class'] ) );
$container_id = esc_attr( $args['id'] ) . '_field';
$field = sprintf( $field_container, $container_class, $container_id, $field_html );
}
$field = apply_filters( 'woocommerce_form_field_' . $args['type'], $field, $key, $args, $value );
if ( $args['return'] ) {
return $field;
} else {
echo $field;
}
}
#Order of fields on Woocommerce checkout form
add_filter("woocommerce_checkout_fields", "ariel_order_fields");
function ariel_order_fields($fields) {
$order = array(
"billing_first_name",
"billing_last_name",
"billing_company",
"billing_email",
"billing_phone",
"billing_country",
"billing_address_1",
"billing_address_2",
"billing_city",
"billing_state",
"billing_postcode",
);
foreach($order as $field)
{
$ordered_fields[$field] = $fields["billing"][$field];
}
$fields["billing"] = $ordered_fields;
return $fields;
}
#WooCommerce sidebar
function ariel_is_active_woocommerce_sidebar(){
if(is_shop()){
if(is_active_sidebar('sidebar-woocommerce')) return true;
if(is_active_sidebar('sidebar-woocommerce-bordered')) return true;
}
if(is_product()){
if(is_active_sidebar('sidebar-woocommerce-product')) return true;
}
if(is_product_category()){
if(is_active_sidebar('sidebar-woocommerce-product-category')) return true;
}
if(is_cart()){
if(is_active_sidebar('sidebar-woocommerce-cart')) return true;
}
if(is_checkout()){
if(is_active_sidebar('sidebar-woocommerce-checkout')) return true;
}
}
/**
* Product review submit button
*
* WooCommerce is using builtin comments functionality for reviews and
* we need different markup surrounding submit button, depending
* on whether user is logged in or out. This function is attached
* to 'comment_form_submit_field' filter hook.
*
* @param string $submit_field Submit button markup
* @param array $args Submit button args
* @return string Returns filtered submit button markup
*/
function ariel_product_review_submit_button( $submit_field, $args ) {
if ( 'product' == get_post_type() ) :
if ( ! is_user_logged_in() ) :
$field = '';
$field .= '';
$field .= $submit_field;
$field .= '
';
$field .= '';
$field .= '';
$field .= '';
else :
$field = '';
$field .= '
';
$field .= $submit_field;
$field .= '
';
$field .= '
';
endif;
return $field;
else :
return $submit_field;
endif;
}
/**
* Shop loop pagination args
*
* Modify prev and next arrows for shop loop pagination. This
* function is attached to 'woocommerce_pagination_args'
* filter hook.
*
* @param array $array Array of pagination args
* @return array Returns filtered array of args
*/
function ariel_woo_pagination( $array ) {
$array['prev_text'] = '';
$array['next_text'] = '';
return $array;
}