%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/shaban/laviva/wp-content/themes/levelup/woocommerce/
Upload File :
Create Path :
Current File : /var/www/html/shaban/laviva/wp-content/themes/levelup/woocommerce/woocommerce-config.php

<?php

global $levelup_options, $woocommerce;

if ( version_compare( $woocommerce->version, "2.1", "<" ) ) {
    define( 'WOOCOMMERCE_USE_CSS', false );
} else {
    add_filter( 'woocommerce_enqueue_styles', 'levelup_woocommerce_enqueue_styles' );
    function levelup_woocommerce_enqueue_styles( $styles ) {
        $styles = array();

        return $styles;
    }
}


if(!function_exists( 'levelup_woo_related_products_args' )) {

    function levelup_woo_related_products_args( $args ) {
        global $levelup_options;

        $args['posts_per_page'] = $levelup_options['wc_related_count'] > 0 ? $levelup_options['wc_related_count'] : 4;

        return $args;
    }

    add_filter( 'woocommerce_output_related_products_args', 'levelup_woo_related_products_args' );
}


function levelup_wc_remove_related_products( $args ) {
    return array();
}

if ( isset( $levelup_options['woo-enable-product-related'] ) && $levelup_options['woo-enable-product-related'] == 0 ) {
    add_filter( 'woocommerce_related_products_args', 'levelup_wc_remove_related_products', 10 );
}


if ( isset( $levelup_options['woo-catalog-count'] ) && $levelup_options['woo-catalog-count'] ) {
    if ( isset( $_GET["shop_special"] ) ) {
        add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 16;' ), 20 );
    } else {
        add_filter( 'loop_shop_per_page', create_function( '$cols', 'return ' . $levelup_options['woo-catalog-count'] . ';' ), 20 );
    }
}

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action('levelup_woocommerce_after_product_image', 'woocommerce_template_loop_add_to_cart', 10);


if ( ! function_exists( 'levelup_woocommerce_taxonomy_archive_description' ) ) {

    function levelup_woocommerce_taxonomy_archive_description() {
        return false;
    }

}

if ( ! function_exists( 'levelup_woocommerce_product_archive_description' ) ) {

    function levelup_woocommerce_product_archive_description() {
        if ( is_post_type_archive( 'product' ) && get_query_var( 'paged' ) == 0 ) {
            $shop_page   = get_post( wc_get_page_id( 'shop' ) );
            if ( $shop_page ) {
                $description = wc_format_content( $shop_page->post_content );
                if ( $description ) {
                    echo '<div class="col-xs-12"><div class="page-description">' . $description . '</div></div>';
                }
            }
        }
    }

}

remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
add_action( 'woocommerce_archive_description', 'levelup_woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_archive_description', 'levelup_woocommerce_product_archive_description', 10 );


function levelup_override_woocommerce_checkout_fields($fields) {
    $args_billing = array(
        'first_name' => esc_html__('First name', 'LEVELUP'),
        'last_name'  => esc_html__('Last name', 'LEVELUP'),
        'company'    => esc_html__('Company name', 'LEVELUP'),
        'address_1'  => esc_html__('Address', 'LEVELUP'),
        'email'      => esc_html__('Email', 'LEVELUP'),
        'phone'      => esc_html__('Phone', 'LEVELUP'),
        'postcode'   => esc_html__('Postcode / ZIP', 'LEVELUP')
    );

    $args_shipping = array(
        'first_name' => esc_html__('First name', 'LEVELUP'),
        'last_name'  => esc_html__('Last name', 'LEVELUP'),
        'company'    => esc_html__('Company name', 'LEVELUP'),
        'address_1'  => esc_html__('Address', 'LEVELUP'),
        'postcode'   => esc_html__('Postcode / ZIP', 'LEVELUP')
    );

    foreach ($args_billing as $key => $value) {
        $fields["billing"]["billing_{$key}"]["placeholder"] = $value;
    }

    foreach ($args_shipping as $key => $value) {
        $fields["shipping"]["shipping_{$key}"]["placeholder"] = $value;
    }

    return $fields;
}
add_filter('woocommerce_checkout_fields', 'levelup_override_woocommerce_checkout_fields');


if ( ! function_exists( 'levelup_woocommerce_output_product_data_tabs' ) ) {

    function levelup_woocommerce_output_product_data_tabs() {
        wc_get_template( 'single-product/tabs/tabs.php' );
        echo '</div>';
    }

}

if ( ! function_exists( 'levelup_woocommerce_template_loop_category' ) ) {

    function levelup_woocommerce_template_loop_category() {
        wc_get_template( 'loop/category.php' );
    }

}

if(!function_exists( 'levelup_woocommerce_change_actions_priorities' )) {

    function levelup_woocommerce_change_actions_priorities() {
        $actions = array(
            array(
                'tag' => 'woocommerce_after_shop_loop_item_title',
                'action' => 'woocommerce_template_loop_price',
                'priority' => 10,
                'priority_to_set' => 10
            ),
            array(
                'tag' => 'woocommerce_after_shop_loop_item_title',
                'action' => 'woocommerce_template_loop_rating',
                'priority' => 5,
                'priority_to_set' => 11
            )
        );

        foreach($actions as $action) {
            remove_action($action['tag'], $action['action'], $action['priority']);
            add_action($action['tag'], $action['action'], $action['priority_to_set']);
        }
    }

    add_action('woocommerce_change_priorities', 'levelup_woocommerce_change_actions_priorities');
    do_action('woocommerce_change_priorities');
}

remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10);
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 11);

add_action('woocommerce_before2_shop_loop_item_title', 'levelup_woocommerce_template_loop_category');


if ( ! function_exists( 'levelup_woocommerce_show_product_loop_out_of_stock_flash' ) ) {
    function levelup_woocommerce_show_product_loop_out_of_stock_flash() {
        wc_get_template( 'loop/out-stock-flash.php' );
    }
}
if ( ! function_exists( 'levelup_woocommerce_show_product_out_of_stock_flash' ) ) {
    function levelup_woocommerce_show_product_out_of_stock_flash() {
        wc_get_template( 'single-product/out-stock-flash.php' );
    }
}
add_action( 'woocommerce_before_shop_loop_item_title', 'levelup_woocommerce_show_product_loop_out_of_stock_flash', 10 );
add_action( 'woocommerce_before_single_product_summary', 'levelup_woocommerce_show_product_out_of_stock_flash', 10 );


if ( ! function_exists( 'levelup_woocommerce_shortcode_before_loop' ) ) {

    function levelup_woocommerce_shortcode_before_loop() {
        echo '<div class="woocommerce-shortcode">';
    }
}
add_action( 'woocommerce_shortcode_before_product_category_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );
add_action( 'woocommerce_shortcode_before_product_categories_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );
add_action( 'woocommerce_shortcode_before_products_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );
add_action( 'woocommerce_shortcode_before_sale_products_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );
add_action( 'woocommerce_shortcode_before_best_selling_products_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );
add_action( 'woocommerce_shortcode_before_top_rated_products_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );
add_action( 'woocommerce_shortcode_before_recent_product_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );
add_action( 'woocommerce_shortcode_before_featured_products_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );
add_action( 'woocommerce_shortcode_before_related_products_loop', 'levelup_woocommerce_shortcode_before_loop', 10 );


if ( ! function_exists( 'levelup_woocommerce_shortcode_after_loop' ) ) {

    function levelup_woocommerce_shortcode_after_loop() {
        echo '</div>';
    }
}
add_action( 'woocommerce_shortcode_after_product_category_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );
add_action( 'woocommerce_shortcode_after_product_categories_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );
add_action( 'woocommerce_shortcode_after_products_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );
add_action( 'woocommerce_shortcode_after_sale_products_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );
add_action( 'woocommerce_shortcode_after_best_selling_products_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );
add_action( 'woocommerce_shortcode_after_top_rated_products_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );
add_action( 'woocommerce_shortcode_after_recent_product_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );
add_action( 'woocommerce_shortcode_after_featured_products_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );
add_action( 'woocommerce_shortcode_after_related_products_loop', 'levelup_woocommerce_shortcode_after_loop', 10 );


function levelup_woocommerce_available_variation( $variation ) {
    if ( has_post_thumbnail( $variation->get_variation_id() ) ) {
        $attachment_id = get_post_thumbnail_id( $variation->get_variation_id() );
        $attachment    = wp_get_attachment_image_src( $attachment_id, 'shop_single'  );
        $image         = $attachment ? current( $attachment ) : '';
    } else {
        $image = $image_link = $image_title = $image_alt = '';
    }

    $variation['image_src'] = $image;

    return $variation;
}


if ( ! function_exists( 'levelup_woocommerce_template_loop_product_thumbnail_full' ) ) {

    function levelup_woocommerce_template_loop_product_thumbnail_full() {
        echo woocommerce_get_product_thumbnail('full');
    }
}


if ( ! function_exists( 'levelup_get_product_categorie' ) ) :

    function levelup_get_product_categorie( $id = '' ) {
        $post_type = 'product_cat';

        $terms = get_the_terms( $id, $post_type );
        if( count($terms) > 0){
            return $terms[0]->name;
        }

    }

endif;


if ( ! function_exists( 'levelup_woocommerce_share' ) ) {
    function levelup_woocommerce_share() {
        global $levelup_options;
        if( $levelup_options['woo-enable-product-social'] != 0){
            levelup_display_share_buttons('product', array( 'echo' => true ));
        }
    }

    add_action('woocommerce_product_meta_end', 'levelup_woocommerce_share');
}


function levelup_woocommerce_breadcrumbs() {
    return array(
        'delimiter'   => ' &#47; ',
        'wrap_before' => '<nav class="woocommerce-breadcrumb">',
        'wrap_after'  => '</nav>',
        'before'      => '',
        'after'       => '',
        'home'        => _x( 'Home', 'breadcrumb', 'LEVELUP' ),
    );
}
add_filter( 'woocommerce_breadcrumb_defaults', 'levelup_woocommerce_breadcrumbs' );

remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
add_action( 'woocommerce_before_main_content_breadcrumb', 'woocommerce_breadcrumb', 20, 0 );


function levelup_override_page_title() {
    return false;
}

add_filter('woocommerce_show_page_title', 'levelup_override_page_title');


function levelup_woocommerce_add_category_header_img() {
    ?>
    <div class="form-field">
        <label><?php esc_html_e( 'Header', 'LEVELUP' ); ?></label>
        <div id="product_cat_header" class="woocommerce_add_category"><img src="<?php echo wc_placeholder_img_src(); ?>" width="60px" height="60px" /></div>
        <div class="line_height_60">
            <input type="hidden" id="product_cat_header_id" name="product_cat_header_id" />
            <button type="submit" class="upload_header_button button"><?php esc_html_e( 'Upload/Add image', 'LEVELUP' ); ?></button>
            <button type="submit" class="remove_header_image_button button"><?php esc_html_e( 'Remove image', 'LEVELUP' ); ?></button>
        </div>

        <script type="text/javascript">

            // Only show the "remove image" button when needed
            if ( ! jQuery('#product_cat_header_id').val() )
                jQuery('.remove_header_image_button').hide();

            // Uploading files
            var header_file_frame;

            jQuery(document).on( 'click', '.upload_header_button', function( event ){

                event.preventDefault();

                // If the media frame already exists, reopen it.
                if ( header_file_frame ) {
                    header_file_frame.open();
                    return;
                }

                // Create the media frame.
                header_file_frame = wp.media.frames.downloadable_file = wp.media({
                    title: '<?php esc_html_e( 'Choose an image', 'LEVELUP' ); ?>',
                    button: {
                        text: '<?php esc_html_e( 'Use image', 'LEVELUP' ); ?>',
                    },
                    multiple: false
                });

                // When an image is selected, run a callback.
                header_file_frame.on( 'select', function() {
                    attachment = header_file_frame.state().get('selection').first().toJSON();
                    jQuery('#product_cat_header_id').val( attachment.id );
                    jQuery('#product_cat_header img').attr('src', attachment.url );
                    jQuery('.remove_header_image_button').show();
                });

                // Finally, open the modal.
                header_file_frame.open();

            });

            jQuery(document).on( 'click', '.remove_header_image_button', function( event ){
                jQuery('#product_cat_header img').attr('src', '<?php echo wc_placeholder_img_src(); ?>');
                jQuery('#product_cat_header_id').val('');
                jQuery('.remove_header_image_button').hide();
                return false;
            });

        </script>

        <div class="clear"></div>

    </div>

<?php

}

add_action( 'product_cat_add_form_fields', 'levelup_woocommerce_add_category_header_img' );


function levelup_woocommerce_edit_category_header( $term, $taxonomy ) {
    $header	= absint(get_term_meta( $term->term_id, 'header', true ));
    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label><?php esc_html_e( 'Hide header', 'LEVELUP' ); ?></label></th>
        <td>
            <div id="product_cat_header" class="woocommerce_add_category">
                <input type="checkbox" name="product_cat_header" value="1" <?php if($header) echo "checked";?>/>
            </div>
            <div class="clear"></div>
        </td>
    </tr>
<?php
}

add_action( 'product_cat_edit_form_fields', 'levelup_woocommerce_edit_category_header', 10, 2 );


function levelup_woocommerce_edit_category_header_img( $term, $taxonomy ) {
    $display_type	= get_term_meta( $term->term_id, 'display_type', true );
    $image 			= '';
    $header_id 	= absint( get_term_meta( $term->term_id, 'header_id', true ) );
    if ($header_id) :
        $image = wp_get_attachment_url( $header_id );
    else :
        $image = wc_placeholder_img_src();
    endif;

    ?>

    <tr class="form-field">
        <th scope="row" valign="top"><label><?php esc_html_e( 'Header', 'LEVELUP' ); ?></label></th>
        <td>
            <div id="product_cat_header" class="woocommerce_add_category"><img src="<?php echo esc_url( $image ); ?>" width="60px" height="60px" /></div>
            <div class="line_height_60">
                <input type="hidden" id="product_cat_header_id" name="product_cat_header_id" value="<?php echo esc_attr( $header_id ); ?>" />
                <button type="submit" class="upload_header_button button"><?php esc_html_e( 'Upload/Add image', 'LEVELUP' ); ?></button>
                <button type="submit" class="remove_header_image_button button"><?php esc_html_e( 'Remove image', 'LEVELUP' ); ?></button>
            </div>

            <script type="text/javascript">

                if (jQuery('#product_cat_thumbnail_id').val() == 0)
                    jQuery('.remove_image_button').hide();

                if (jQuery('#product_cat_header_id').val() == 0)
                    jQuery('.remove_header_image_button').hide();

                // Uploading files
                var header_file_frame;

                jQuery(document).on( 'click', '.upload_header_button', function( event ){

                    event.preventDefault();

                    // If the media frame already exists, reopen it.
                    if ( header_file_frame ) {
                        header_file_frame.open();
                        return;
                    }

                    // Create the media frame.
                    header_file_frame = wp.media.frames.downloadable_file = wp.media({
                        title: '<?php esc_html_e( 'Choose an image', 'LEVELUP' ); ?>',
                        button: {
                            text: '<?php esc_html_e( 'Use image', 'LEVELUP' ); ?>',
                        },
                        multiple: false
                    });

                    // When an image is selected, run a callback.
                    header_file_frame.on( 'select', function() {
                        attachment = header_file_frame.state().get('selection').first().toJSON();
                        jQuery('#product_cat_header_id').val( attachment.id );
                        jQuery('#product_cat_header img').attr('src', attachment.url );
                        jQuery('.remove_header_image_button').show();
                    });

                    // Finally, open the modal.
                    header_file_frame.open();
                });

                jQuery(document).on( 'click', '.remove_header_image_button', function( event ){
                    jQuery('#product_cat_header img').attr('src', '<?php echo wc_placeholder_img_src(); ?>');
                    jQuery('#product_cat_header_id').val('');
                    jQuery('.remove_header_image_button').hide();
                    return false;
                });

            </script>

            <div class="clear"></div>

        </td>

    </tr>

<?php

}

add_action( 'product_cat_edit_form_fields', 'levelup_woocommerce_edit_category_header_img', 10,2 );


function levelup_woocommerce_edit_category_header_color( $term, $taxonomy ) {
    $color	= get_term_meta( $term->term_id, 'color', true );
    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label><?php esc_html_e( 'Color', 'LEVELUP' ); ?></label></th>
        <td>
            <div id="product_cat_header" class="woocommerce_add_category">
                <input type="text" name="product_cat_color" value="<?php echo esc_attr( $color );?>" class="cat-color-field" />
            </div>
            <script>
                jQuery(document).ready(function($){
                    $('.cat-color-field').wpColorPicker();
                });
            </script>
            <div class="clear"></div>
        </td>
    </tr>
<?php
}

add_action( 'product_cat_edit_form_fields', 'levelup_woocommerce_edit_category_header_color', 10,2 );


function levelup_woocommerce_edit_category_header_textcolor( $term, $taxonomy ) {
    $color	= get_term_meta( $term->term_id, 'textcolor', true );
    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label><?php esc_html_e( 'Text Color', 'LEVELUP' ); ?></label></th>
        <td>
            <div id="product_cat_header" class="woocommerce_add_category">
                <select id="textcolor" name="product_cat_textcolor">
                    <option value="dark"<?php if(!$color || $color == 'dark'):?> selected="selected"<?php endif;?>>Default (Dark)</option>
                    <option value="light"<?php if($color == 'light'):?> selected="selected"<?php endif;?>>Light</option>
                </select>
            </div>
            <div class="clear"></div>
        </td>
    </tr>
<?php
}

add_action( 'product_cat_edit_form_fields', 'levelup_woocommerce_edit_category_header_textcolor', 10, 2 );


function levelup_woocommerce_edit_category_header_padding_top( $term, $taxonomy ) {
    $padding = get_term_meta( $term->term_id, 'padding_top', true );
    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label><?php esc_html_e( 'Padding top', 'LEVELUP' ); ?></label></th>
        <td>
            <div class="woocommerce_add_category">
                <input type="text" name="product_cat_padding_top" value="<?php echo esc_attr( $padding );?>" />
            </div>
            <div class="clear"></div>
        </td>
    </tr>
<?php
}

add_action( 'product_cat_edit_form_fields', 'levelup_woocommerce_edit_category_header_padding_top', 10, 2 );


function levelup_woocommerce_edit_category_header_padding_bottom( $term, $taxonomy ) {
    $padding = get_term_meta( $term->term_id, 'padding_bottom', true );
    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label><?php esc_html_e( 'Padding bottom', 'LEVELUP' ); ?></label></th>
        <td>
            <div class="woocommerce_add_category">
                <input type="text" name="product_cat_padding_bottom" value="<?php echo esc_attr( $padding );?>" />
            </div>
            <div class="clear"></div>
        </td>
    </tr>
<?php
}

add_action( 'product_cat_edit_form_fields', 'levelup_woocommerce_edit_category_header_padding_bottom', 10,2 );


function levelup_woocommerce_category_header_save( $term_id, $tt_id, $taxonomy ) {

    if ( isset( $_POST['product_cat_header_id'] ) )
	    update_term_meta( $term_id, 'header_id', absint( $_POST['product_cat_header_id'] ) );
    if ( isset( $_POST['product_cat_color'] ) )
	    update_term_meta( $term_id, 'color', $_POST['product_cat_color'] );
    if ( isset( $_POST['product_cat_textcolor'] ) )
	    update_term_meta( $term_id, 'textcolor', $_POST['product_cat_textcolor'] );

    if ( isset( $_POST['product_cat_header'] ) )
	    update_term_meta( $term_id, 'header', absint( $_POST['product_cat_header'] ) );
    else
	    update_term_meta( $term_id, 'header', 0 );

    if ( isset( $_POST['product_cat_padding_top'] ) )
	    update_term_meta( $term_id, 'padding_top', absint( $_POST['product_cat_padding_top'] ) );

    if ( isset( $_POST['product_cat_padding_bottom'] ) )
	    update_term_meta( $term_id, 'padding_bottom', absint( $_POST['product_cat_padding_bottom'] ) );

    delete_transient( 'wc_term_counts' );

}

add_action( 'created_term', 'levelup_woocommerce_category_header_save', 10,3 );
add_action( 'edit_term', 'levelup_woocommerce_category_header_save', 10,3 );


function levelup_woocommerce_product_cat_header_columns( $columns ) {
    $new_columns = array();
    $new_columns['cb'] = $columns['cb'];
    $new_columns['thumb'] = esc_html__( 'Image', 'LEVELUP' );
    $new_columns['header'] = esc_html__( 'Header', 'LEVELUP' );
    unset( $columns['cb'] );
    unset( $columns['thumb'] );

    return array_merge( $new_columns, $columns );
}

add_filter( 'manage_edit-product_cat_columns', 'levelup_woocommerce_product_cat_header_columns' );


function levelup_woocommerce_product_cat_header_column( $columns, $column, $id ) {
    if ( $column == 'header' ) {
        $image 			= '';
        $thumbnail_id 	= get_term_meta( $id, 'header_id', true );

        if ($thumbnail_id)
            $image = wp_get_attachment_url( $thumbnail_id );
        else
            $image = wc_placeholder_img_src();

        $columns .= '<img src="' . esc_url( $image ) . '" alt="Thumbnail" class="wp-post-image" height="40" width="40" />';
    }

    return $columns;
}

add_filter( 'manage_product_cat_custom_column', 'levelup_woocommerce_product_cat_header_column', 10, 3 );


function levelup_woocommerce_get_header_category($cat_ID = false) {
    if ($cat_ID == false && is_product_category()){
        global $wp_query;
        $cat = $wp_query->get_queried_object();
        $cat_ID = $cat->term_id;
    }

    $header = get_term_meta($cat_ID, 'header', true );

    return $header;
}


function levelup_woocommerce_get_header_image_url($cat_ID = false) {
    if ($cat_ID==false && is_product_category()){
        global $wp_query;
        $cat = $wp_query->get_queried_object();
        $cat_ID = $cat->term_id;
    }

    $header = get_term_meta($cat_ID, 'header_id', true );

    return wp_get_attachment_url( $header );
}


function levelup_woocommerce_get_header_color($cat_ID = false) {
    if ($cat_ID==false && is_product_category()){
        global $wp_query;
        $cat = $wp_query->get_queried_object();
        $cat_ID = $cat->term_id;
    }

    $out = get_term_meta($cat_ID, 'color', true );

    return $out;
}


function levelup_woocommerce_get_header_textcolor($cat_ID = false) {
    if ($cat_ID==false && is_product_category()){
        global $wp_query;
        $cat = $wp_query->get_queried_object();
        $cat_ID = $cat->term_id;
    }

    $out = get_term_meta($cat_ID, 'textcolor', true );
    if($out == "dark"){
        $out = "";
    }

    return $out;
}


function levelup_woocommerce_get_header_padding_top($cat_ID = false) {
    if ($cat_ID==false && is_product_category()){
        global $wp_query;
        $cat = $wp_query->get_queried_object();
        $cat_ID = $cat->term_id;
    }

    $out = get_term_meta($cat_ID, 'padding_top', true );

    return $out;
}


function levelup_woocommerce_get_header_padding_bottom($cat_ID = false) {
    if ($cat_ID==false && is_product_category()){
        global $wp_query;
        $cat = $wp_query->get_queried_object();
        $cat_ID = $cat->term_id;
    }

    $out = get_term_meta($cat_ID, 'padding_bottom', true );

    return $out;

}


if (!function_exists( 'levelup_header_cart_fragment' )) {
    function levelup_header_cart_fragment()
    {
        ob_start();
        ?>

        <div class="rdy_dynamic_shopping_bag">
            <div class="rdy_little_shopping_bag_wrapper shopping_bag_default_style shopping_bag_in_header
            ">

                <div class="rdy_minicart_wrapper">
                    <div class="rdy_minicart">
                        <?php
                        echo '<ul class="cart_list">';
                        if ( count( WC()->cart->cart_contents ) > 0 ) : foreach ( WC()->cart->cart_contents as $cart_item_key => $cart_item ) :

                            $_product = $cart_item['data'];
                            if ( $_product->exists() && $cart_item['quantity'] > 0 ) :
                                echo '<li class="cart_list_product">';
                                echo '<a class="cart_list_product_img" href="' . get_permalink( $cart_item['product_id'] ) . '">' . $_product->get_image() . '</a>';
                                echo '<div class="cart_list_product_title">';
                                $product_title = $_product->get_title();
                                echo '<a href="' . get_permalink( $cart_item['product_id'] ) . '">' . apply_filters( 'woocommerce_cart_widget_product_title', $product_title, $_product ) . '</a>';
                                echo '<div class="cart_list_product_quantity">' . esc_html__( 'Quantity:', 'LEVELUP' ) . ' ' . $cart_item['quantity'] . '</div>';
                                echo '<div class="cart_list_product_price">' . wc_price( $_product->get_price() ) . '</div>';
                                echo '</div>';
                                echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf( '<a href="%s" class="remove" title="%s"></a>', esc_url( WC()->cart->get_remove_url( $cart_item_key ) ), esc_html__( 'Remove this item', 'LEVELUP' ) ), $cart_item_key );
                                echo '<div class="clear"></div>';
                                echo '</li>';
                            endif;
                        endforeach;
                            ?>

                            <div class="minicart_total_checkout clearfix">
                                <?php esc_html_e('Total', 'LEVELUP'); ?><?php echo WC()->cart->get_cart_total(); ?>
                            </div>

                            <div class="minicart_cart_button clearfix">
                                <a href="<?php echo wc_get_cart_url(); ?>" class="b_button rdy_minicart_cart_but"><?php esc_html_e('View Cart',  'LEVELUP'); ?></a>
                                <a href="<?php echo wc_get_checkout_url(); ?>" class="b_button rdy_minicart_checkout_but"><?php esc_html_e('Checkout',  'LEVELUP'); ?></a>
                            </div>
                            <?php
                        else: echo '<li class="empty">'.esc_html__('No products in the cart.', 'LEVELUP').'</li>'; endif;
                        echo '</ul>';
                        ?>

                    </div>
                </div>

            </div>

            <a href="<?php echo wc_get_cart_url(); ?>" class="rdy_little_shopping_bag_wrapper_mobiles"><span><?php echo WC()->cart->cart_contents_count; ?></span></a>

        </div>
        <?php

        return ob_get_clean();

    }
}


if (!function_exists( 'levelup_woocommerceframework_header_add_to_cart_fragment' )) {
    function levelup_woocommerceframework_header_add_to_cart_fragment( $fragments ) {

        $fragments['.rdy_dynamic_shopping_bag'] = levelup_header_cart_fragment();
        return $fragments;
    }
}
add_filter('woocommerce_add_to_cart_fragments', 'levelup_woocommerceframework_header_add_to_cart_fragment');


function levelup_woocommerce_header_add_to_cart_fragment( $fragments ) {
    ob_start();
    ?>
    <span class="header_cart_span"><?php echo WC()->cart->cart_contents_count; ?></span>
    <?php
    $fragments['span.header_cart_span'] = ob_get_clean();
    return $fragments;
}
add_filter('woocommerce_add_to_cart_fragments', 'levelup_woocommerce_header_add_to_cart_fragment');


remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );

//add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
add_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
add_action( 'woocommerce_cross_sell_display', 'woocommerce_cross_sell_display' );


remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );

add_action( 'woocommerce_before_shop_loop_result_count', 'woocommerce_result_count', 20 );
add_action( 'woocommerce_before_shop_loop_catalog_ordering', 'woocommerce_catalog_ordering', 30 );


function levelup_woocommerce_checkout_before_customer_details(){
    echo '<div class="col-md-7 col-xs-12">';
}

function levelup_woocommerce_checkout_after_customer_details(){
    echo '</div>';
}

function levelup_woocommerce_checkout_before_order_review(){
    echo '<div class="col-md-5 col-xs-12">';
}

function levelup_woocommerce_checkout_after_order_review(){
    echo '</div>';
}

add_action( 'woocommerce_checkout_before_customer_details', 'levelup_woocommerce_checkout_before_customer_details', 20, 0 );
add_action( 'woocommerce_checkout_after_customer_details', 'levelup_woocommerce_checkout_after_customer_details', 20, 0 );
add_action( 'woocommerce_checkout_before_order_review', 'levelup_woocommerce_checkout_before_order_review', 20, 0 );
add_action( 'woocommerce_checkout_after_order_review', 'levelup_woocommerce_checkout_after_order_review', 20, 0 );


function levelup_woocommerce_before_checkout_form(){
    echo '<div class="col0-xs-12 row">';
}

function levelup_woocommerce_after_checkout_form(){
    echo '</div>';
}

add_action( 'woocommerce_before_checkout_form', 'levelup_woocommerce_before_checkout_form', 20, 0 );
add_action( 'woocommerce_after_checkout_form', 'levelup_woocommerce_after_checkout_form', 20, 0 );


function levelup_woocommerce_product_review_comment_form_args( $comment_form ){
    $comment_form['class_submit'] = 'submit button alt';

    return $comment_form;
};
add_filter( 'woocommerce_product_review_comment_form_args', 'levelup_woocommerce_product_review_comment_form_args', 10, 1 );


function levelup_woocommerce_price_format() {
    $currency_pos = get_option( 'woocommerce_currency_pos' );

	switch ( $currency_pos ) {
        case 'left' :
            $format = '<span class="currency">%1$s</span>%2$s';
            break;
        case 'right' :
            $format = '%2$s<span class="currency">%1$s</span>';
            break;
        case 'left_space' :
            $format = '<span class="currency">%1$s</span>&nbsp;%2$s';
            break;
        case 'right_space' :
            $format = '%2$s&nbsp;<span class="currency">%1$s</span>';
            break;
    }

	return $format;
}
add_filter( 'woocommerce_price_format', 'levelup_woocommerce_price_format', 10, 2 );


function levelup_vc_remove_woocommerce() {
    if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
        vc_remove_element("woocommerce_cart");
        vc_remove_element("woocommerce_checkout");
        vc_remove_element("woocommerce_order_tracking");
        vc_remove_element("woocommerce_my_account");
    }
}
add_action( 'vc_build_admin_page', 'levelup_vc_remove_woocommerce', 11 );


function levelup_wc_product_columns_frontend() {
    $wc_columns = levelup_get_options("woo_columns");

    $columns = $wc_columns;

    return $columns;
}
add_filter('loop_shop_columns', 'levelup_wc_product_columns_frontend');


function levelup_woocommerce_output_related_products()
{
    $number_of_columns = levelup_get_options("wc_related_columns");

    $args = array(
        'posts_per_page' => $number_of_columns,
        'columns' => $number_of_columns,
        'orderby' => 'rand'
    );

    woocommerce_related_products( apply_filters( 'woocommerce_output_related_products_args', $args ) );
}
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
add_action('woocommerce_after_single_product_summary', 'levelup_woocommerce_output_related_products', 20);


if ( ! function_exists( 'levelup_woocommerce_add_config_actions' ) ) :

    function levelup_woocommerce_add_config_actions() {
        $config = levelup_config();
        add_action( 'dt_wc_loop_start', array( $mod_wc_config, 'setup' ) );
        add_action( 'dt_wc_loop_end', array( $mod_wc_config, 'cleanup' ) );
    }

endif;


if ( ! function_exists( 'levelup_woocommerce_init_template_config' ) ) :

    function levelup_woocommerce_init_template_config( $name = '' ) {

        if ( 'shop' != $name ) {
            return;
        }

        $config = levelup_config();
        $post_id = null;

        if ( is_shop() ) {
            $post_id = wc_get_page_id( 'shop' );

        } else if ( is_cart() ) {
            $post_id = wc_get_page_id( 'cart' );

        } else if ( is_checkout() ) {
            $post_id = wc_get_page_id( 'checkout' );

        }

        levelup_config_base_init( $post_id );

    }

    add_action( 'get_header', 'levelup_woocommerce_init_template_config', 10 );

endif;


if (  ! function_exists( 'levelup_woocommerce_template_loop_category_title' ) ) {

    function levelup_woocommerce_template_loop_category_title( $category ) {
        ?>
        <div class="figcaption">
        <div class="col-table">
        <div class="col-td">
            <h3>
                <?php
                echo esc_html( $category->name );
                ?>
            </h3>
            <?php
            if ( $category->count > 0 )
                echo apply_filters( 'woocommerce_subcategory_count_html', ' <span class="count">' . sprintf( _n( '%s item', '%s items', $category->count, 'LEVELUP' ), $category->count ) . '</span>', $category );
            ?>
        </div>
        </div>
        </div>
        <?php
    }
}

remove_action( 'woocommerce_shop_loop_subcategory_title', 'woocommerce_template_loop_category_title', 10 );
add_action( 'woocommerce_shop_loop_subcategory_title', 'levelup_woocommerce_template_loop_category_title', 10 );


function levelup_woocommerce_catalog_placeholder_img_src() {
    return LEVELUP_TEMPLATE_URL . '/assets/images/catalog_placeholder.png';
}


if ( ! function_exists( 'levelup_woocommerce_subcategory_thumbnail' ) ) {

    function levelup_woocommerce_subcategory_thumbnail( $category ) {
        $small_thumbnail_size  	= apply_filters( 'single_product_small_thumbnail_size', 'levelup-portfolio-thumb' );
        $dimensions    			= wc_get_image_size( $small_thumbnail_size );
        $thumbnail_id  			= get_term_meta( $category->term_id, 'thumbnail_id', true  );

        if ( $thumbnail_id ) {
            $image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size  );
            $image = $image[0];
        } else {
            add_filter('woocommerce_placeholder_img_src', 'levelup_woocommerce_catalog_placeholder_img_src');
            $image = wc_placeholder_img_src();
        }

        if ( $image ) {
            $image = str_replace( ' ', '%20', $image );

            echo '<img src="' . esc_url( $image ) . '" alt="' . esc_attr( $category->name ) . '" />';
        }
    }
}

remove_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 );
add_action( 'woocommerce_before_subcategory_title', 'levelup_woocommerce_subcategory_thumbnail', 10 );


add_filter( 'wp_calculate_image_srcset_meta', '__return_null' );


if ( ! function_exists( 'levelup_woocommerce_get_star_rating_html' ) ) {

	function levelup_woocommerce_get_star_rating_html( $html, $rating, $count ) {
		$html = '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%">';
    	$html .= '</span>';

        return $html;
	}

}
add_filter( 'woocommerce_get_star_rating_html', 'levelup_woocommerce_get_star_rating_html', 10, 3 );

Zerion Mini Shell 1.0