복붙노트

[WORDPRESS] 가격이 0이 될 때 장바구니에 추가 버튼 "요청 : 요청 요청"[복제]

WORDPRESS

가격이 0이 될 때 장바구니에 추가 버튼 "요청 : 요청 요청"[복제]

해결법


  1. 1.이 기능을 기능에 넣으십시오 .php.

    이 기능을 기능에 넣으십시오 .php.

    add_filter('woocommerce_get_price_html', 'requestQuote', 10, 2);
    
    function requestQuote($price, $product) {
            if ( $price == wc_price( 0.00 ) ){
    
                     remove_action( 'woocommerce_single_product_summary', 
          'woocommerce_template_single_add_to_cart', 30 );
                     return 'Request Quote';
            }
    
    
            else{
                return $price;}
        }
    

  2. 2.기능이있는 경우 조건을 만들어야합니다.

    기능이있는 경우 조건을 만들어야합니다.

        $price = 2000;
        $response = 'Add To Cart;
        if(size = XL)
        {
           $price = 0;
           $response = "You can Request another Size";
        }
    
  3. from https://stackoverflow.com/questions/49408965/when-price-is-0-change-add-to-cart-button-to-request-quote by cc-by-sa and MIT license