Okay
  Public Ticket #3515429
Hiding product description and price raising from purchasing price
Closed

Comments

  • Muzaffer Altinok started the conversation

    Hello there,


    I need some help. I have purchased B2B king plugin new. But i need more extra details, 

    1- I want to hide product description when i select hide price selection on plugin.

    2- I have created purchase price area with 'Cost of Goods Sold (COGS)' plugin. Dynamic price rules are working from regular price, but i want to work it with my purchasig price. Is it possible?


    Thanks for your helps. :)

  •  2,218
    WebWizards replied

    Hello Muzaffer,

    Thank you for purchasing our plugin,


    (1) To hide descriptions for products, for logged out users, you can add this PHP code snippet to your site:

    add_filter( 'woocommerce_product_tabs', 'customize_product_tabs', 100 );
    function customize_product_tabs( $tabs ) {
        if ( ! is_user_logged_in() ) { 
            unset( $tabs['description'] ); // remove the description tab
        }
        
        return $tabs;
    }
    add_filter('woocommerce_short_description', function($description){
        if ( ! is_user_logged_in() ) { 
            $description = false;
        }
        return $description;
    }, 10, 1);
    

    (2) This depends on each rule and I do not have a way to apply it to all rules.

    However, I wrote a snippet that can make this work for Discount rules, and for Raise price rules:

    add_filter('b2bking_discount_rule_regular_price', function($price, $product){
        $product_id = $product->get_id();
        $costprice = get_post_meta($product_id,'_alg_wc_cog_cost', true);
        if (!empty($costprice)){
            $price = floatval($costprice);
        }
        return $price;
    }, 10, 2);
    

    For example, I have a rule that raises price by 50%:

    9196501696.png

    I have a product with a cost of $25:

    1091140628.png

    The price will show as $37.5 (cost x 150%)

    3538796399.png



    The above PHP snippets can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/


    Kind regards,

    Stefan