• Resolved TRS DEV

    (@tecrocketspace)


    Hi, Im using a custom code to show different prices on cart based on payment gateway. It was working fine but now this error is popping up, my payment gateways doesnt work.

    Notice: Undefined variable: increaseby_sam in /public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(582) : eval()’d code on line 24

    this is my part of the code,

    line 24 is

    $cart_item[‘data’]->set_price( $price + ( $price * $increaseby_sam ) / 97 );

    ?I don’t know how to repair the snippet code would you mind helping me to fix the issue?

    thanks

    if ( $chosen_payment_method == 'samipg' ) {
         $increaseby_sam = 3;
    }
    
    // Loop through cart items
    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {     
        // Get price
        $price = $cart_item['data']->get_price();
    
        // Set price
         $cart_item['data']->set_price( $price + ( $price * $increaseby_sam ) / 97 );
    
    }
    • This topic was modified 11 months, 1 week ago by TRS DEV.
Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    You’re only setting the $increaseby_sam variable when the payment method is samipg.

    Perhaps provide it with a default value for other payment methods? I’m not really sure what you are trying to achieve here, but 1 seems like a reasonable default value.

    
    $increaseby_sam = 1
    
    if ( $chosen_payment_method == 'samipg' ) {
         $increaseby_sam = 3;
    }
    
    // Loop through cart items
    foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {     
        // Get price
        $price = $cart_item['data']->get_price();
    
        // Set price
         $cart_item['data']->set_price( $price + ( $price * $increaseby_sam ) / 97 );
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Notice: Undefined Variable:’ is closed to new replies.