0

I have some problems with displaying some values and I have no idea what I did wrong.

    <?php
/*
 Plugin Name: Wallet for WooCommerce
 Plugin URI:
 Description: Wallet for a Client
 Version: 1.0
 Author: InDeepTerror
 Author URI:
 */

 include( plugin_dir_path( __FILE__ ) . 'wallet.php');
include( plugin_dir_path( __FILE__ ) . 'settings.php');


$wallet = New wallet();

 add_action( 'woocommerce_product_options_general_product_data', 'getPerProduct');

 add_action( 'woocommerce_process_product_meta', 'save_wallet_option');

?>

<?php

/** * Class wallet * * @param int $customer_id Current customer ID * */

class wallet {

function __construct()
{
        if ($this->checkEcommerce()) {
            add_filter( 'woocommerce_account_menu_items', 'account_menu_hook');
            add_filter( 'woocommerce_account_menu_items', 'account_wallet_menu');
            add_action( 'woocommerce_account_wallet-endpoint', 'displayWallet');
            add_action( 'wp_login', 'walletOwner', 99);
            add_action( 'woocommerce_created_customer', 'createPointsField');
} else
            throw new Exception('WooCommerce is not Installed. The plugin Requires WooCommerce', 7);
}

function checkEcommerce() {
    if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
        return true;
    }
    return false;
}

function walletOwner($login) {
$user = get_user_by('login',$login);
    $user_id = $user->ID;
    return $user_id;
}

function displayWallet() {
/*    $userID = $this->walletOwner();
    $this->getUserPoints($userID);
echo "<span> <b>". $amount . "</b> </span>"
;*/
echo "TEST!";
}
function newMenuWP($pagetitle, $menu_title, $capability, $menu_slug, $function, $position, $icon_url) {
    add_menu_page( $pagetitle, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
}
function getPerPrice($percentage) {

}
function WPMenu(){
    echo '';
}
function getPerCategory($points) {

}
function getPerProduct() {
    global $woocommerce, $post;

    echo '<div class="options_group">';

    woocommerce_wp_text_input(
        array(
            'id'    => '_number_field',
            'label' => __( 'MoneyBack Wallet', 'woocommerce' ),
            'placeholder' => '',
            'description' => __( 'Enter the product percentage points'),
            'type'        => 'number',
            'custom_attributes' => array(
                'step' => '0.1',
                'min'  => '0',
                'max'  => '100',
            )
        )
    );

    echo '</div>';
}
function isAffiliate($product_id) {

}
function SignUpBonus($bonus) {

}
function setSignUpBonus($bonus_amount) {

}
function addPoints($add_points) {

}
function convertPoints($points)
{

}

function save_wallet_option()
{
    $woocommerce_number_field = $_POST['_number_field'];
    if (!empty($woocommerce_number_field)) {
        update_post_meta($post_id, '_number_field', esc_attr($woocommerce_number_field));
    }
}
function account_menu_hook($items) {
$items['wallet-endpoint'] = __('Wallet EndPoint', 'woocommerce');
    return $items;
}
function account_menu_insert_position($items, $new_items, $location) {
    $position = array_search( $after, array_keys( $items ) );
    $array = array_slice( $items, 0, $position, true );
    $array += $new_items;
    $array += array_slice( $items, $position, count( $items ) - $position, true );

    return $array;
}
function account_wallet_menu($items) {
    $new_items = array();
    $new_items['wallet-endpoint'] = __('Wallet EndPoint', 'woocommerce');

    return $this->account_menu_insert_position($items, $new_items, 'dashboard');
}
function getUserPoints($user_id) {

  $points = get_user_meta($user_id, 'points', true);

  if (!isset($points)) {
      $this->createPointsField();
      return $points = $this->SignUpBonus();
  }

    return $points;
}
function createPointsField($customer_id) {
add_user_meta($customer_id, 'points', $this->SignUpBonus());
}

} ?>

The errors I get in add new product:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'getPerProduct' not found or invalid function name in /home/styleadda/developers.styleadda.in/wp-includes/plugin.php on line 524

The errors I get in myaccount:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'account_menu_hook' not found or invalid function name in /home/styleadda/developers.styleadda.in/wp-includes/plugin.php on line 235

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'account_wallet_menu' not found or invalid function name in /home/styleadda/developers.styleadda.in/wp-includes/plugin.php on line 235

Warning: Invalid argument supplied for foreach() in /home/styleadda/developers.styleadda.in/wp-content/plugins/woocommerce/templates/myaccount/navigation.php on line 28

0

You need to correct how you call function in your class, if the function you want to use is in the class, for the add_action: add_action( 'woocommerce_account_wallet-endpoint', array($this, 'displayWallet') ); add_action( 'wp_login', array($this, 'walletOwner'), 99);

Replace all add_action or filter like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.