Give_Customer::update PHP Method

update() public method

Update a customer record
Since: 1.0
public update ( array $data = [] ) : boolean
$data array Array of data attributes for a customer (checked via whitelist).
return boolean If the update was successful or not.
    public function update($data = array())
    {
        if (empty($data)) {
            return false;
        }
        $data = $this->sanitize_columns($data);
        do_action('give_customer_pre_update', $this->id, $data);
        $updated = false;
        if ($this->db->update($this->id, $data)) {
            $customer = $this->db->get_customer_by('id', $this->id);
            $this->setup_customer($customer);
            $updated = true;
        }
        do_action('give_customer_post_update', $updated, $this->id, $data);
        return $updated;
    }

Usage Example

Ejemplo n.º 1
0
 public function test_update_customer()
 {
     $test_email = '*****@*****.**';
     $customer = new Give_Customer($test_email);
     $customer_id = $customer->create(array('email' => $test_email));
     $this->assertEquals($customer_id, $customer->id);
     $data_to_update = array('email' => '*****@*****.**', 'name' => 'Test Account');
     $customer->update($data_to_update);
     $this->assertEquals('*****@*****.**', $customer->email);
     $this->assertEquals('Test Account', $customer->name);
     // Verify if we have an empty array we get false
     $this->assertFalse($customer->update());
 }
All Usage Examples Of Give_Customer::update