• Resolved cfhd31

    (@cfhd31)


    Hi! i want add to the orders, the button of whatsapp. The error is Call to a member function get_id() on null.. Can you help me?
    Thanks!!

    
    add_action('wcfm_orders_module_actions',function( $actions,$order ) {
    	$the_order = wc_get_order( $order->order_id );
    
    $telefono_numero = get_user_meta( $user_id, 'xoo_ml_phone_no', true );
    $telefono_code = get_user_meta( $user_id, 'xoo_ml_phone_code', true );
    $telefono_code1=substr($telefono_code,1);
    $tel=$telefono_code1+$telefono_numero;
    $telefono_completo= 'https://wa.me/'.$tel;
    
    $actions = '<a class="wcfm_order_mark_complete wcfm-action-icon" href="#" data-orderid="' . $the_order->ID . '"><span class="wcfmfa fa-check-circle text_tip" data-tip="' . esc_attr__( 'Entregado', 'wc-frontend-manager' ) . '"></span></a>';
    $actions .= '<a class="wcfm-action-icon" href="' . get_wcfm_view_order_url($the_order->get_id(), $the_order). '"><span class="wcfmfa fa-eye text_tip" data-tip="' . esc_attr__( 'Ver', 'wc-frontend-manager' ) . '"></span></a>';
    $actions .= '<a class="wcfm-action-icon" href="'.$telefono_completo.'"><span class="fa fa-whatsapp text_tip" data-tip="' . esc_attr__( 'Mandar WhatsApp', 'wc-frontend-manager' ) . '"></span></a>';
    return $actions;
    
    }, 50, 2 );
    
    • This topic was modified 4 years, 8 months ago by cfhd31.
    • This topic was modified 4 years, 8 months ago by cfhd31.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WC Lovers

    (@wclovers)

    Hi,

    Please try this revised code –

    add_action('wcfm_orders_module_actions',function( $actions, $order_id, $the_order ) {
    	if( $the_order->get_user_id() ) {
    		$user_id = $the_order->get_user_id();
    		$telefono_numero = get_user_meta( $user_id, 'xoo_ml_phone_no', true );
    		$telefono_code = get_user_meta( $user_id, 'xoo_ml_phone_code', true );
    		$telefono_code1 = substr($telefono_code,1);
    		$tel = $telefono_code1.$telefono_numero;
    		$telefono_completo= 'https://wa.me/'.$tel;
    		
    		$actions .= '<a class="wcfm-action-icon" target="_blank" href="'.$telefono_completo.'"><span class="fa fa-whatsapp text_tip" data-tip="' . esc_attr__( 'Mandar WhatsApp', 'wc-frontend-manager' ) . '"></span></a>';
    	}
    	return $actions;
    }, 50, 3 );

    Thank You

    Thread Starter cfhd31

    (@cfhd31)

    You are awesome! Thanks!

    Plugin Author WC Lovers

    (@wclovers)

    You are always welcome!

    If you ever get a chance then please leave a review for me ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Button in orders list’ is closed to new replies.