コード例 #1
0
ファイル: Guest.php プロジェクト: jigoshop/Jigoshop2
 public function getStateToSave()
 {
     $state = parent::getStateToSave();
     unset($state['id'], $state['login'], $state['email'], $state['name']);
     $state['billing'] = serialize($state['billing']);
     $state['shipping'] = serialize($state['shipping']);
     return $state;
 }
コード例 #2
0
ファイル: Order.php プロジェクト: jigoshop/Jigoshop2
 /**
  * @return array List of fields to update with according values.
  */
 public function getStateToSave()
 {
     $shipping = false;
     if (is_object($this->shippingMethod)) {
         $shipping = $this->shippingMethod->getState();
     }
     $payment = false;
     if (is_object($this->paymentMethod)) {
         $payment = $this->paymentMethod->getId();
     }
     return array('id' => $this->id, 'number' => $this->number, 'updated_at' => $this->updatedAt->getTimestamp(), 'completed_at' => $this->completedAt ? $this->completedAt->getTimestamp() : 0, 'items' => $this->items, 'customer' => serialize($this->customer), 'customer_id' => $this->customer->getId(), 'shipping' => array('method' => $shipping, 'price' => $this->shippingPrice, 'rate' => $this->shippingMethodRate), 'payment' => $payment, 'customer_note' => $this->customerNote, 'total' => $this->total, 'subtotal' => $this->subtotal, 'discount' => $this->discount, 'coupons' => $this->coupons, 'shipping_tax' => $this->shippingTax, 'status' => $this->status, 'update_messages' => $this->updateMessages);
 }
コード例 #3
0
ファイル: Customer.php プロジェクト: jigoshop/Jigoshop2
 /**
  * Fetches customer from database.
  *
  * @param $user \WP_User User object to fetch customer for.
  *
  * @return \Jigoshop\Entity\Customer
  */
 public function fetch($user)
 {
     $state = array();
     if ($user->ID == 0) {
         $customer = new Entity\Guest();
         if ($this->session->getField(self::CUSTOMER)) {
             $customer->restoreState($this->session->getField(self::CUSTOMER));
         }
     } else {
         $customer = new Entity();
         $meta = $this->wp->getUserMeta($user->ID);
         if (is_array($meta)) {
             $state = array_map(function ($item) {
                 return $item[0];
             }, $meta);
         }
         $state['id'] = $user->ID;
         $state['login'] = $user->get('login');
         $state['email'] = $user->get('user_email');
         $state['name'] = $user->get('display_name');
         $customer->restoreState($state);
     }
     return $this->wp->applyFilters('jigoshop\\find\\customer', $customer, $state);
 }
コード例 #4
0
ファイル: Cart.php プロジェクト: jigoshop/Jigoshop2
 private function updateCustomer(Customer $customer)
 {
     $address = $customer->getShippingAddress();
     if ($customer->hasMatchingAddresses()) {
         $billingAddress = $customer->getBillingAddress();
         $billingAddress->setCountry($_POST['country']);
         $billingAddress->setState($_POST['state']);
         $billingAddress->setPostcode($_POST['postcode']);
     }
     $address->setCountry($_POST['country']);
     $address->setState($_POST['state']);
     $address->setPostcode($_POST['postcode']);
 }
コード例 #5
0
ファイル: Checkout.php プロジェクト: jigoshop/Jigoshop2
 /**
  * Abstraction for location update response.
  *
  * Prepares and returns array of updated data for location change requests.
  *
  * @param Customer   $customer The customer (for location).
  * @param CartEntity $cart     Current cart.
  *
  * @return array
  */
 private function getAjaxLocationResponse(Customer $customer, CartEntity $cart)
 {
     $response = $this->getAjaxCartResponse($cart);
     $address = $customer->getShippingAddress();
     // Add some additional fields
     $response['has_states'] = Country::hasStates($address->getCountry());
     $response['states'] = Country::getStates($address->getCountry());
     $response['html']['estimation'] = $address->getLocation();
     return $response;
 }
コード例 #6
0
ファイル: Orders.php プロジェクト: jigoshop/Jigoshop2
 private function _migrateCustomer($customer, $data)
 {
     $data = $this->_fetchCustomerData($data);
     if (!$customer) {
         $customer = new Customer();
     } else {
         $customer = maybe_unserialize(maybe_unserialize($customer));
     }
     if (!$customer instanceof Customer) {
         $customer = new Customer();
     }
     if (!empty($data['billing_company']) && !empty($data['billing_euvatno'])) {
         $address = new Customer\CompanyAddress();
         $address->setCompany($data['billing_company']);
         $address->setVatNumber($data['billing_euvatno']);
     } else {
         $address = new Customer\Address();
     }
     $address->setFirstName($data['billing_first_name']);
     $address->setLastName($data['billing_last_name']);
     $address->setAddress($data['billing_address_1'] . ' ' . $data['billing_address_2']);
     $address->setCountry($data['billing_country']);
     $address->setState($data['billing_state']);
     $address->setPostcode($data['billing_postcode']);
     $address->setPhone($data['billing_phone']);
     $address->setEmail($data['billing_email']);
     $customer->setBillingAddress($address);
     if (!empty($data['shipping_company'])) {
         $address = new Customer\CompanyAddress();
         $address->setCompany($data['shipping_company']);
     } else {
         $address = new Customer\Address();
     }
     $address->setFirstName($data['shipping_first_name']);
     $address->setLastName($data['shipping_last_name']);
     $address->setAddress($data['shipping_address_1'] . ' ' . $data['shipping_address_2']);
     $address->setCountry($data['shipping_country']);
     $address->setState($data['shipping_state']);
     $address->setPostcode($data['shipping_postcode']);
     $customer->setShippingAddress($address);
     return $customer;
 }
コード例 #7
0
 /**
  * Checks whether provided customer needs to be taxed.
  *
  * @param Entity $customer Customer to check.
  *
  * @return boolean Whether customer needs to be taxed.
  */
 public function isTaxable(Entity $customer)
 {
     $country = $this->options->get('general.country');
     $customerCountry = $customer->getTaxAddress()->getCountry();
     if (Country::isEU($country)) {
         return Country::isEU($customerCountry);
     }
     return $country == $customerCountry;
 }