From 7f04fe822aa1a4b59c52cb5a516c899270962685 Mon Sep 17 00:00:00 2001 From: Dima Uryvskiy Date: Fri, 18 Mar 2022 15:57:42 +0300 Subject: [PATCH] Add a check for the existence of a method in a class --- src/include/class-wc-retailcrm-customers.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/include/class-wc-retailcrm-customers.php b/src/include/class-wc-retailcrm-customers.php index 844d7e1..5e92a2d 100644 --- a/src/include/class-wc-retailcrm-customers.php +++ b/src/include/class-wc-retailcrm-customers.php @@ -632,7 +632,9 @@ if (!class_exists('WC_Retailcrm_Customers')) : $new_customer = new WC_Customer(); foreach ($order->get_address('billing') as $prop => $value) { - $new_customer->{'set_billing_' . $prop}($value); + if (method_exists($new_customer, 'set_billing_' . $prop)) { + $new_customer->{'set_billing_' . $prop}($value); + } } $new_customer->set_first_name($order->get_billing_first_name());