public function __construct($user = array(), $order = array())
 {
     $this->datasources = array("user" => $user, "order" => $order);
     $profile = commerce_customer_profile_load($order->commerce_customer_billing[LANGUAGE_NONE][0]['profile_id']);
     $this->datasources['profile'] = $profile;
     $this->datasources['extra'] = array("moneda" => "ARS");
 }
 /**
  * Default constructor for the Commerce Customer Profile.
  *
  * @param int $order_id
  *   Order id if an existing order is to be loaded.
  */
 public function __construct($profile_id = NULL)
 {
     if (!is_null($profile_id) && is_numeric($profile_id)) {
         $profile = commerce_customer_profile_load($profile_id);
         if (!$profile) {
             $this->setErrors("Profile with id {$profile} does not exist.");
             $this->setInitialized(FALSE);
             return;
         }
     } else {
         global $user;
         $class = new \ReflectionClass(get_called_class());
         $type = Utils::makeSnakeCase($class->getShortName());
         $profile = commerce_customer_profile_new($type, $user->uid);
     }
     parent::__construct($profile);
 }
 /**
  * Create or update a card with a web service response
  */
 protected function processCardResponse(&$context)
 {
     // Exit if not enough info
     if (empty($context['response']) || empty($context['state'])) {
         return;
     }
     // Exit if request failed
     if (empty($context['response']['transaction_approved'])) {
         return;
     }
     $response = $context['response'];
     $state =& $context['state'];
     // Exit if no transarmor response
     if (empty($response['transarmor_token'])) {
         return;
     }
     // Extract card values from the response
     $new_values = $this->createResponseCardValues($response, $state);
     // Reference card and create new if needed
     $card =& $state['card'];
     if (empty($card)) {
         // New cards
         $card = commerce_cardonfile_new($new_values);
         $new_values = array();
     } elseif (!empty($card->card_id)) {
         // Existing card - only care if remote id changed or type was determined
         $new_values = array_intersect_key($new_values, array('remote_id' => 1, 'card_type' => 1));
     }
     // Exit if set not to store
     if (!empty($card->no_store)) {
         return;
     }
     // Determine new billing profile
     $new_billing_profile = NULL;
     $existing_billing_profile = NULL;
     if (!empty($card->commerce_cardonfile_profile[LANGUAGE_NONE][0]['profile_id'])) {
         $existing_billing_profile = commerce_customer_profile_load($card->commerce_cardonfile_profile[LANGUAGE_NONE][0]['profile_id']);
     }
     if (!empty($state['billing_address'])) {
         $create_billing = TRUE;
         if (!empty($existing_billing_profile)) {
             $existing_billing_profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $existing_billing_profile);
             if ($this->controller->addressIsEqual($state['billing_address'], $existing_billing_profile_wrapper->commerce_customer_address->value())) {
                 $create_billing = FALSE;
             }
         }
         if ($create_billing) {
             if (!empty($state['billing_profile_id'])) {
                 $resolved_billing_profile = commerce_customer_profile_load($state['billing_profile_id']);
                 $resolved_billing_profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $resolved_billing_profile);
                 if ($this->controller->addressIsEqual($state['billing_address'], $resolved_billing_profile_wrapper->commerce_customer_address->value())) {
                     $new_billing_profile = $resolved_billing_profile;
                 }
             }
             if (!$new_billing_profile) {
                 $new_billing_profile = commerce_customer_profile_new('billing', $card->uid);
                 $new_billing_profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $new_billing_profile);
                 $new_billing_profile_wrapper->commerce_customer_address = $state['billing_address'] + addressfield_default_values();
             }
         }
     }
     // If new card ...
     if (empty($card->card_id)) {
         // Check required properties
         if (empty($card->uid) || empty($card->payment_method) || empty($card->instance_id)) {
             /** @todo: ??? **/
             return;
         }
     }
     // Create / Update the card
     $this->saveCard($card, $new_billing_profile, $new_values);
 }
 /**
  * @Given /^"(?P<type>[^"]*)" bookings:$/
  */
 public function createBookings($type, TableNode $nodesTable)
 {
     foreach ($nodesTable->getHash() as $nodeHash) {
         $profile_id = $this->customerProfiles[$nodeHash['profile_id']];
         $profile = commerce_customer_profile_load($profile_id);
         $client_name = isset($profile->commerce_customer_address['und'][0]['name_line']) ? $profile->commerce_customer_address['und'][0]['name_line'] : $nodeHash['profile_id'];
         // Save customer in rooms_customers table.
         db_merge('rooms_customers')->key(array('name' => $client_name))->fields(array('name' => $client_name, 'commerce_customer_id' => $profile_id))->execute();
         // Get customer id from rooms_customers table.
         $client_id = db_select('rooms_customers')->fields('rooms_customers', array('id'))->condition('name', $client_name, '=')->execute()->fetchField();
         $unit_id = $this->findBookableUnitByName($nodeHash['unit']);
         $unit = rooms_unit_load($unit_id);
         $unit_type = $unit->type;
         $data = array('type' => $type, 'name' => $client_name, 'customer_id' => $client_id, 'unit_id' => $unit_id, 'unit_type' => $unit_type, 'start_date' => $nodeHash['start_date'], 'end_date' => $nodeHash['end_date'], 'booking_status' => $nodeHash['status'], 'data' => array('group_size' => $nodeHash['guests'], 'group_size_children' => $nodeHash['children']));
         $booking = rooms_booking_create($data);
         $booking->save();
         $start_date = new \DateTime($nodeHash['start_date']);
         $end_date = new \DateTime($nodeHash['end_date']);
         $booking_parameters = array('adults' => $nodeHash['guests'], 'children' => $nodeHash['children']);
         $order = rooms_booking_manager_create_order($start_date, $end_date, $booking_parameters, $unit, $booking, $client_id);
         $booking->order_id = $order->order_number;
         $booking->save();
         $this->bookings[] = $booking->booking_id;
     }
 }
Exemple #5
0
 $form_vars['last-name'] = $customershipping->field_last_name['und'][0]['value'];
 $form_vars['telefon'] = $customershipping->field_telefon['und'][0]['value'];
 $form_vars['email'] = $o->mail;
 $form_vars['birth-date'] = date("d.m.Y", strtotime($customershipping->field_birthday['und'][0]['value']));
 $customershippinganrede = $customershipping->field_anrede['und'][0]['value'];
 if ($customershippinganrede == "Herr") {
     $customershippinganrede = "Herr";
     $u_title = "Sehr geehrter Herr" . $form_vars['title'];
 } elseif ($customershippinganrede == "Frau") {
     $customershippinganrede = "Frau";
     $u_title = "Sehr geehrte Frau" . $form_vars['title'];
 }
 $form_vars['sex'] = $customershippinganrede;
 // billing
 $billing_profile_id = $o->commerce_customer_billing['und'][0]['profile_id'];
 $customerbilling = commerce_customer_profile_load($billing_profile_id);
 file_put_contents('/tmp/123-bill', print_r($billing_profile, TRUE));
 file_put_contents('/tmp/123-o', print_r($o, TRUE));
 if (!empty($customerbilling->commerce_customer_address['und'][0]['thoroughfare'])) {
     $form_vars['rechnungs-adresse'] = $customerbilling->commerce_customer_address['und'][0]['thoroughfare'] . ' ' . $customerbilling->field_hausnummer['und'][0]['value'] . '/' . $customerbilling->field_stiege['und'][0]['value'] . '/' . $customerbilling->field_t_r['und'][0]['value'];
     $form_vars['rechnungs-plz'] = $customerbilling->commerce_customer_address['und'][0]['postal_code'];
     $form_vars['rechnungs-ort'] = $customerbilling->commerce_customer_address['und'][0]['locality'];
 } else {
     $form_vars['rechnungs-adresse'] = $customershipping->commerce_customer_address['und'][0]['thoroughfare'] . ' ' . $customershipping->field_hausnummer['und'][0]['value'] . '/' . $customershipping->field_stiege['und'][0]['value'] . '/' . $customerbilling->field_t_r['und'][0]['value'];
     $form_vars['rechnungs-plz'] = $customershipping->commerce_customer_address['und'][0]['postal_code'];
     $form_vars['rechnungs-ort'] = $customershipping->commerce_customer_address['und'][0]['locality'];
 }
 $orderwechselumzug = $o->field_wechseloderumzug['und'][0]['value'];
 if ($orderwechselumzug == "umzug") {
     $ordervorlieferant = "Kein bestehender Lieferant";
 } else {