commit
f698e1c7b2
@ -1,10 +1,10 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.4
|
|
||||||
- 5.5
|
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
@ -15,8 +15,6 @@ env:
|
|||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- php: 5.3
|
|
||||||
dist: precise
|
|
||||||
- php: 7.2
|
- php: 7.2
|
||||||
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1
|
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1
|
||||||
|
|
||||||
|
@ -172,8 +172,8 @@ if (!class_exists('WC_Retailcrm_Customers')) :
|
|||||||
*/
|
*/
|
||||||
public function searchCustomer($filter)
|
public function searchCustomer($filter)
|
||||||
{
|
{
|
||||||
if (isset($filter['id'])) {
|
if (isset($filter['externalId'])) {
|
||||||
$search = $this->retailcrm->customersGet($filter['id']);
|
$search = $this->retailcrm->customersGet($filter['externalId']);
|
||||||
} elseif (isset($filter['email'])) {
|
} elseif (isset($filter['email'])) {
|
||||||
$search = $this->retailcrm->customersList(array('email' => $filter['email']));
|
$search = $this->retailcrm->customersList(array('email' => $filter['email']));
|
||||||
}
|
}
|
||||||
|
@ -125,38 +125,45 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$order = wc_get_order($order_id);
|
$wcOrder = wc_get_order($order_id);
|
||||||
$this->processOrder($order);
|
$this->processOrder($wcOrder);
|
||||||
$customer = $order->get_user();
|
$wpUser = $wcOrder->get_user();
|
||||||
|
|
||||||
if ($customer != false) {
|
if ($wpUser instanceof WP_User) {
|
||||||
$search = $this->customers->searchCustomer(array('id' => $customer->get('ID')));
|
$wpUserId = (int)$wpUser->get('ID');
|
||||||
|
$foundCustomer = $this->customers->searchCustomer(array(
|
||||||
|
'externalId' => $wpUserId
|
||||||
|
));
|
||||||
|
|
||||||
if (!$search) {
|
if (empty($foundCustomer)) {
|
||||||
$this->customers->createCustomer($customer);
|
$customerId = $this->customers->createCustomer($wpUserId);
|
||||||
} else {
|
|
||||||
$this->order['customer']['externalId'] = $search['externalId'];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$search = $this->customers->searchCustomer(array('email' => $order->get_billing_email()));
|
|
||||||
|
|
||||||
if (!$search) {
|
if (!empty($customerId)) {
|
||||||
$new_customer = $this->customers->buildCustomerFromOrderData($order);
|
$this->order['customer']['id'] = $customerId;
|
||||||
$id = $this->customers->createCustomer($new_customer);
|
|
||||||
|
|
||||||
if ($id !== null) {
|
|
||||||
$this->order['customer']['id'] = $id;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->order['customer']['externalId'] = $search['externalId'];
|
$this->order['customer']['externalId'] = $foundCustomer['externalId'];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$foundCustomer = $this->customers->searchCustomer(array(
|
||||||
|
'email' => $wcOrder->get_billing_email()
|
||||||
|
));
|
||||||
|
|
||||||
unset($new_customer);
|
if (empty($foundCustomer)) {
|
||||||
|
$wcCustomer = $this->customers->buildCustomerFromOrderData($wcOrder);
|
||||||
|
$customerId = $this->customers->createCustomer($wcCustomer);
|
||||||
|
|
||||||
|
if (!empty($customerId)) {
|
||||||
|
$this->order['customer']['id'] = $customerId;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->order['customer']['externalId'] = $foundCustomer['externalId'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->retailcrm->ordersCreate($this->order);
|
$this->retailcrm->ordersCreate($this->order);
|
||||||
|
|
||||||
return $order;
|
return $wcOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,8 +77,13 @@ class WC_Retailcrm_Order_Item extends WC_Retailcrm_Abstracts_Data
|
|||||||
$uid = ($item['variation_id'] > 0) ? $item['variation_id'] : $item['product_id'] ;
|
$uid = ($item['variation_id'] > 0) ? $item['variation_id'] : $item['product_id'] ;
|
||||||
$offer = array('externalId' => $uid);
|
$offer = array('externalId' => $uid);
|
||||||
|
|
||||||
if (isset($this->settings['bind_by_sku']) && $this->settings['bind_by_sku'] == WC_Retailcrm_Base::YES) {
|
$product = $item->get_product();
|
||||||
$offer['xmlId'] = $item->get_product()->get_sku();
|
|
||||||
|
if (!empty($product) &&
|
||||||
|
isset($this->settings['bind_by_sku']) &&
|
||||||
|
$this->settings['bind_by_sku'] == WC_Retailcrm_Base::YES
|
||||||
|
) {
|
||||||
|
$offer['xmlId'] = $product->get_sku();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_data_field('offer', $offer);
|
$this->set_data_field('offer', $offer);
|
||||||
|
@ -73,6 +73,8 @@ install_woocommerce() {
|
|||||||
git clone https://github.com/woocommerce/woocommerce.git
|
git clone https://github.com/woocommerce/woocommerce.git
|
||||||
cd woocommerce
|
cd woocommerce
|
||||||
git checkout master
|
git checkout master
|
||||||
|
composer install
|
||||||
|
npm install
|
||||||
cd -
|
cd -
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user