• Good afternoon. Prompt with a question please. I have a price calculator and, in addition to the quantity, the length is also taken into account: 2 pieces of 10 meters each – an example. I have changed the plugin code. Introduced a variable from the calculator plugin and replaced the line in ITEMS.

    В файле:

    /wp-content/plugins/notification-for-telegram/index.php
    // product_meters - line 520
    $product_meters = wc_get_order_item_meta($item_id, ‘Length of one piece (m)’, true);
    
    // line 535 - Can't think of anything better than this
    if ($product_meters) {
    $linea = $linea . $quantity . ?pieces. x ? . $product_meters . ?meters. x ? . $item_name . ? — ? . $line_total . ? ? . $currency_code . $extrafiledhook . ?\r\n?;
    } else {
    $linea = $linea . $quantity . ?pieces. x ? . $item_name . ? — ? . $line_total . ? ? . $currency_code . $extrafiledhook . ?\r\n?;
    }

    Is it possible to change the line

    $linea = $linea.$quantity." x " .$item_name . " - ". $line_total." ". $currency_code.$extrafiledhook."\r\n" ;

    and add a variable via a function without changing your plugin code? So that the changes are not overwritten with updates? Perhaps through a filter somehow?

    • This topic was modified 1 year, 3 months ago by polarone.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author rainafarai

    (@rainafarai)

    Next realease i will add new Hooks : Product rows Filter with 2 different behaviors ADD or REPLACE LINE
    You will receave 3 arguments : $message ,$product_id, $item !!
    Wait next update V 3.0 ( im working on it)

    
    
    
    <?php
    add_filter('nftb_order_product_line_hook', 'my_item_line_function', 10, 3);
    
    function my_item_line_function($message ,$product_id, $item) {
    
        // ADD SOME CODE $product_id TO ORIGINAL row $message.
        $modified_data = $message. "->".$product_id. "\r\n";
    
        // REPLACE Product ITEM LINE CODE WITH YOUR CODE  without concatenate $message.
        $modified_data = $product_id. "\r\n";
    
        return $modified_data;
    } 
    ?>
    Plugin Author rainafarai

    (@rainafarai)

    New release 3.0 ready tell me if the hooks works !!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Changing the code and adding an arbitrary notification.’ is closed to new replies.