Support » Plugin: Woocommerce Ajax add to cart for variable products » Not Working on my site

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Rishi Mehta

    (@rcreators)

    Hi,

    You need to assign “product-type-variable” Class to your right sidebar gray box. without this class button click event will not work.

    Thread Starter auonhaidar

    (@auonhaidar)

    Hi Rishi
    Thanks for your quick reply.
    Sorry I have not understood what you just said.
    I am developing this website using a purchased theme and making most of the changes through WordPress.
    Can you please tell me where to do this what you just said.
    Thanks.

    Plugin Author Rishi Mehta

    (@rcreators)

    Hi,

    You need to go to your theme folder->woocommerce->conten-single.php file find how html is generated and than find right side gray box of cart and apply “product-type-variable” to it.

    I suggest if you are not developer, don’t do it yourself. let me know details of your website (FTP) and will add it from my side.

    Thread Starter auonhaidar

    (@auonhaidar)

    I can send content-single-product.php file for now. See if you can point me in the right direction. The code follows:

    <?php
    /**
    * The template for displaying product content in the single-product.php template
    *
    * Override this template by copying it to yourtheme/woocommerce/content-single-product.php
    *
    * @author WooThemes
    * @package WooCommerce/Templates
    * @version 1.6.4
    */

    if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly

    wp_enqueue_script( ‘jquery-selectbox’ );

    // grouped fix
    global $product;
    if ( $product->product_type == ‘grouped’ && yit_get_option(‘shop-detail-show-price’) ) {
    remove_action( ‘yit_product_box’, ‘woocommerce_template_single_add_to_cart’, 20 );
    add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
    }
    ?>

    <?php
    /**
    * woocommerce_before_single_product hook
    *
    * @hooked woocommerce_show_messages – 10
    */
    do_action( ‘woocommerce_before_single_product’ );

    if ( post_password_required() ) {
    echo get_the_password_form();
    return;
    }

    ?>
    <div class=”row”>

    <?php
    /**
    * woocommerce_show_product_images hook
    *
    * @hooked woocommerce_show_product_sale_flash – 10
    * @hooked woocommerce_show_product_images – 20
    */
    do_action( ‘woocommerce_before_single_product_summary’ );
    ?>

    <div class=”summary entry-summary”>

    <?php
    /**
    * woocommerce_single_product_summary hook
    *
    * @hooked woocommerce_template_single_title – 5
    * @hooked woocommerce_template_single_rating – 10
    * @hooked woocommerce_template_single_price – 10
    * @hooked woocommerce_template_single_excerpt – 20
    * @hooked woocommerce_template_single_add_to_cart – 30
    * @hooked woocommerce_template_single_meta – 40
    * @hooked woocommerce_template_single_sharing – 50
    */
    do_action( ‘woocommerce_single_product_summary’ );
    ?>

    <?php if( yit_product_form_position_is(‘in-content’) ) yit_product_single_boxmeta() ?>

    </div><!– .summary –>
    <?php
    /**
    * woocommerce_after_single_product_summary hook
    *
    * @hooked woocommerce_output_product_data_tabs – 10
    * @hooked woocommerce_output_related_products – 20
    */
    do_action( ‘woocommerce_after_single_product_summary’ );
    ?>

    </div>
    <?php do_action( ‘woocommerce_after_single_product’ ); ?>

    Thread Starter auonhaidar

    (@auonhaidar)

    Hey Rishi
    I think I got it.

    This is my sidebar-shop.php file in my theme folder.

    <?php
    /**
    * Your Inspiration Themes
    *
    * @package WordPress
    * @subpackage Your Inspiration Themes
    * @author Your Inspiration Themes Team <info@yithemes.com>
    *
    * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
    * that is bundled with this package in the file LICENSE.txt.
    * It is also available through the world-wide-web at this URL:
    * http://www.gnu.org/licenses/gpl-3.0.txt
    */

    wp_reset_query();

    do_action( ‘yit_before_sidebar_’ . sanitize_title( yit_get_choosen_sidebar() ) ) ?>
    <!– START SIDEBAR –>
    <div id=”sidebar-<?php echo sanitize_title( yit_get_choosen_sidebar() ) ?>” class=”span3 sidebar group”>
    <?php
    // product detail page box meta
    if ( yit_product_form_position_is(‘in-sidebar’) ) yit_product_single_boxmeta();

    if( yit_get_sidebar_layout() != ‘sidebar-no’ && ( !function_exists( ‘dynamic_sidebar’ ) || !dynamic_sidebar( yit_get_choosen_sidebar() ) ) )
    { do_action( ‘yit_default_sidebar’ ); }
    ?>
    </div>
    <!– END SIDEBAR –>
    <?php do_action( ‘yit_after_sidebar_’ . sanitize_title( yit_get_choosen_sidebar() ) ) ?>

    I changed its class from ‘span3 sidebar group’ to ‘product-type-variable’ and it worked. But my div got all messed up.
    Why is that?

    Thread Starter auonhaidar

    (@auonhaidar)

    I got it right finally!
    Used this thread of yours – https://wordpress.org/support/topic/running-a-plugin-to-show-products?replies=5

    Thanks a lot!

    Thread Starter auonhaidar

    (@auonhaidar)

    There is still one thing. On this page http://www.smurfers.com/shop/lannister/ when you select product,quantity and size and press add to cart, it updates cart. There are two problems-
    1) At top left- cart still says -‘Empty Cart’. How to change this?
    2) When I hover on it, it says product, its quantity and total price but NOT its variation (size). Can you tell me why is this happening?

    Thanks in advance.

    Thread Starter auonhaidar

    (@auonhaidar)

    Hi Rishi,
    Please tell me how to change ‘EMPTY CART’ text to ‘VIEW CART’ in cart widget at top of my page : http://www.smurfers.com/shop/lannister/

    When you click on ‘ADD TO CART’ button after selecting variation and quantity, AJAX works and cart widget at top-left gets updated. BUT ‘EMPTY CART’ text does not get changed to ‘VIEW CART’.
    Previously. when I was not using your plugin, the whole page was getting reloaded when I press ‘add to cart’ and then ‘EMPTY CART’ text changes to ‘VIEW CART’.
    With your AJAX, perhaps this text change is not happening.
    FYI This text layout is in my /theme/widgets/YIT_Widget_cart.php

    Please help. Atleast tell me where to look.

    Thanks for your kind help till now.

    Plugin Author Rishi Mehta

    (@rcreators)

    Hi,

    You need to check your class of cart text and push another function after ajax fired to change empty cart to view cart text. you can do it through jquery also.

    Thread Starter auonhaidar

    (@auonhaidar)

    My class of cart text is “cart_control” when cart is not empty and “cart_control_empty” when cart is empty.
    Here are the lines of my cart function YIT_Widget_cart.php:

    if($yit_is_header) :
    if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) : ?>
    cart->get_cart_url(); ?>” class=”cart_control”><?php _e(‘View Cart’, ‘yit’) ?>
    <?php else: ?>
    cart->get_cart_url(); ?>” class=”cart_control” style=”display: none;”><?php _e(‘View Cart’, ‘yit’) ?>
    <?php echo apply_filters( ‘yit_widget_header_empty_cart’, __(‘Empty Cart’, ‘yit’) ) ?>
    <?php endif ?>
    <div class=”cart_wrapper”>
    <?php endif;

    Now what function should I add?

    Thanks.

    Thread Starter auonhaidar

    (@auonhaidar)

    Okay done. I got it right.
    I just toggled class of ‘Empty Cart’ anchor to ‘View Cart’ using your jquery and few jquery commands.
    Thanks a lot for your support.

    Plugin Author Rishi Mehta

    (@rcreators)

    Hi,

    Glad you find out solution. Plugin is working Good for default woocommerce classes but as Theme auther changes many things and creates custom classes and function. It was found difficult to create global working patern for mini cart.

    Thread Starter auonhaidar

    (@auonhaidar)

    Yes. I totally agree. That’s why it took too much time. I have to go in each and every relevant folders to find my cart class. Thanks for guidance. I think php is worth learning. I know basic php (designing and mysql stuff) but I don’t know these ‘action’ and ‘hook’ things. Can you suggest some site where I can learn it properly?

    Plugin Author Rishi Mehta

    (@rcreators)

    Thread Starter auonhaidar

    (@auonhaidar)

    Thanks a lot!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Not Working on my site’ is closed to new replies.