Plugin Directory

Changeset 3388784


Ignore:
Timestamp:
11/03/2025 10:54:54 AM (4 months ago)
Author:
mithublue
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • woo-auction/trunk/public/class-woo-auction-product-handler.php

    r3388741 r3388784  
    3939     */
    4040    private function init_hooks() {
    41         // Replace add to cart form with bidding box
    42         remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
     41        // Ensure add to cart is only replaced for auction products
     42        add_action( 'woocommerce_before_single_product', array( $this, 'setup_single_product_hooks' ) );
    4343        add_action( 'woocommerce_single_product_summary', array( $this, 'display_auction_bidding_box' ), 30 );
    4444
     
    4848        // Add bid history after product tabs
    4949        add_action( 'woocommerce_after_single_product_summary', array( $this, 'display_bid_history' ), 15 );
     50    }
     51
     52    /**
     53     * Prepare single product hooks based on product type.
     54     *
     55     * @since 1.0.0
     56     */
     57    public function setup_single_product_hooks() {
     58        global $product;
     59
     60        if ( ! $product ) {
     61            return;
     62        }
     63
     64        if ( 'auction' === $product->get_type() ) {
     65            remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
     66        } else {
     67            // Make sure non-auction products retain the default add to cart button
     68            add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
     69        }
    5070    }
    5171
Note: See TracChangeset for help on using the changeset viewer.