Home Forums Themes Support Claue add "add to cart" button to homepage thumbnail

Viewing 7 reply threads
  • Author
    Posts
    • #4335

      How to add “add to cart” and “quantity” plus minus to homepage (somewhere at the bottom of the price)

      Attachments:
      You must be logged in to view attached files.
    • #4337

      is it copy the exact code as below and paste there?

      <?php if ( ! defined( ‘ABSPATH’ ) ) {
      exit;
      }

      global $product;

      if ( ! $product->is_purchasable() ) {
      return;
      }

      $ajax_btn = get_option( ‘woocommerce_enable_ajax_add_to_cart_single’ );
      $redirect = get_option( ‘woocommerce_cart_redirect_after_add’ );

      echo wc_get_stock_html( $product );

      if ( $product->is_in_stock() ) : ?>

      <?php do_action( ‘woocommerce_before_add_to_cart_form’ ); ?>

      <form class=”cart” method=”post” enctype=’multipart/form-data’>
      <?php
      /**
      * @since 2.1.0.
      */
      do_action( ‘woocommerce_before_add_to_cart_button’ );

      /**
      * @since 3.0.0.
      */
      do_action( ‘woocommerce_before_add_to_cart_quantity’ );

      woocommerce_quantity_input( array(
      ‘min_value’ => apply_filters( ‘woocommerce_quantity_input_min’, $product->get_min_purchase_quantity(), $product ),
      ‘max_value’ => apply_filters( ‘woocommerce_quantity_input_max’, $product->get_max_purchase_quantity(), $product ),
      ‘input_value’ => isset( $_POST[‘quantity’] ) ? wc_stock_amount( $_POST[‘quantity’] ) : $product->get_min_purchase_quantity(),
      ) );

      /**
      * @since 3.0.0.
      */
      do_action( ‘woocommerce_after_add_to_cart_quantity’ );
      ?>

      <?php if ( $ajax_btn == ‘no’ || $redirect == ‘yes’ ) { ?>
      <button type=”submit” name=”add-to-cart” value=”<?php echo esc_attr( $product->get_id() ); ?>” class=”single_add_to_cart_button button alt”><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
      <?php } else { ?>
      <input type=”hidden” name=”add-to-cart” value=”<?php echo esc_attr( $product->get_id() ); ?>” />

      <button type=”submit” name=”add-to-cart” class=”single_add_to_cart_button button alt”><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
      <?php } ?>

      <?php
      /**
      * @since 2.1.0.
      */
      do_action( ‘woocommerce_after_add_to_cart_button’ );
      ?>
      </form>

      <?php do_action( ‘woocommerce_after_add_to_cart_form’ ); ?>

      <?php endif; ?>

    • #4338

      Hi,

      You can put that code into functions.php of claue child theme. Where did you get this code?

    • #4339

      from ../single-product/add-to-cart/simple.php

      put what code into functions.php? how to do?

    • #4340

      No, You can do like this, let me research and give  you the solution

    • #4341

      Hi,

      You can use this code https://pastebin.com/C0nhXLfr add it into functions.php file of child theme

       

      Foster

    • #4342

      thanks… prefect! you are the best hehe

    • #4381

      Hope you love our theme and take a time to help us give our theme good review at https://themeforest.net/downloads. We really appreciate.

      Thank you so much!

      Harry
      Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio

Viewing 7 reply threads

You must be logged in to reply to this topic.