Skip to content

Commit

Permalink
Merge pull request #45 from wuunder/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
TimD90 authored Apr 16, 2020
2 parents 680ec3b + 9f10cd5 commit 74a6b40
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 53 deletions.
Binary file modified .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Released

## [2.7.16](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.16) - 2020-03-23

### Fixed
- Fixed some PHP warnings in hook method code

## [2.7.15](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.15) - 2020-03-17

### Added
Expand Down
6 changes: 3 additions & 3 deletions includes/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function prefix_wc_rest_prepare_order_object($response, $object, $request)
try {
$order = new WC_Order($object->get_id());
$shipping_object = $order->get_items('shipping');
if (count($shipping_method) > 0) {
if (count($shipping_object) > 0) {
$shipping_method_id = wcwp_get_filter_from_shippingmethod(reset($shipping_object)->get_method_id());
}
} catch (Exception $e) {
Expand Down Expand Up @@ -194,11 +194,11 @@ function wcwp_check_parcelshop_selection()
{
if ('wuunder_parcelshop' === sanitize_text_field($_POST['shipping_method'][0])) {
if (!$_POST['parcelshop_id']) {
wc_add_notice(__('Kies eerst een <strong>parcelshop</strong>'), 'error');
wc_add_notice(__('First choose a <strong>parcelshop</strong>'), 'error');
}

if ($_POST['parcelshop_id'] && (!isset($_POST['shipping_country']) || $_POST['shipping_country'] != $_POST['parcelshop_country'])) {
wc_add_notice(__('Het <strong>land van de verzendgegevens</strong> moet overeenkomen met het <strong>land van de parcelshop</strong> '), 'error');
wc_add_notice(__('The <strong>shipping country</strong> must match with <strong>the parcelshop country</strong>'), 'error');
}
}
}
Expand Down
33 changes: 23 additions & 10 deletions includes/wcwuunder-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,15 @@ public function wcwp_get_company_address()
* @param $order_meta , $suffix
* @return $order_meta
*/
private function wcwp_get_customer_address_part($order_meta, $suffix)
private function wcwp_get_customer_address_part($order_meta, $suffix, $prefix = null)
{
if (!is_null($prefix)){
if (isset($order_meta[$prefix . $suffix]) && !empty($order_meta[$prefix . $suffix][0])) {
return $order_meta[$prefix . $suffix][0];
}
return null;
}

if (isset($order_meta['_shipping' . $suffix]) && !empty($order_meta['_shipping' . $suffix][0])) {
return $order_meta['_shipping' . $suffix][0];
} else if (isset($order_meta['_billing' . $suffix]) && !empty($order_meta['_billing' . $suffix][0])) {
Expand All @@ -288,20 +295,26 @@ public function wcwp_get_customer_address($orderid)
$order_meta = get_post_meta($orderid);
$deliveryAddress = new \Wuunder\Api\Config\AddressConfig();

$address_line_1 = $this->wcwp_get_customer_address_part($order_meta, '_address_1');
$address_line_2 = $this->wcwp_get_customer_address_part($order_meta, '_address_2');
$prefix = "_shipping";
if (!isset($order_meta['_shipping_address_1']) || empty($order_meta['_shipping_address_1'])) {
$prefix = "_billing";
}

$address_line_1 = $this->wcwp_get_customer_address_part($order_meta, '_address_1', $prefix);
$address_line_2 = $this->wcwp_get_customer_address_part($order_meta, '_address_2', $prefix);

$deliveryAddress->setEmailAddress($this->wcwp_get_customer_address_part($order_meta, '_email'));
$deliveryAddress->setFamilyName($this->wcwp_get_customer_address_part($order_meta, '_last_name'));
$deliveryAddress->setGivenName($this->wcwp_get_customer_address_part($order_meta, '_first_name'));
$deliveryAddress->setLocality($this->wcwp_get_customer_address_part($order_meta, '_city'));
$deliveryAddress->setEmailAddress($this->wcwp_get_customer_address_part($order_meta, '_email', $prefix));
$deliveryAddress->setFamilyName($this->wcwp_get_customer_address_part($order_meta, '_last_name', $prefix));
$deliveryAddress->setGivenName($this->wcwp_get_customer_address_part($order_meta, '_first_name', $prefix));
$deliveryAddress->setLocality($this->wcwp_get_customer_address_part($order_meta, '_city', $prefix));
$deliveryAddress->setStreetName($address_line_1);
$deliveryAddress->setAddress2($address_line_2);
$deliveryAddress->setHouseNumber('-');
$deliveryAddress->setZipCode(str_replace(' ', '', $this->wcwp_get_customer_address_part($order_meta, '_postcode')));
$deliveryAddress->setZipCode(str_replace(' ', '', $this->wcwp_get_customer_address_part($order_meta, '_postcode', $prefix)));
$deliveryAddress->setPhoneNumber($order_meta['_billing_phone'][0]);
$deliveryAddress->setCountry($this->wcwp_get_customer_address_part($order_meta, '_country'));
$deliveryAddress->setBusiness($this->wcwp_get_customer_address_part($order_meta, '_company'));
$deliveryAddress->setCountry($this->wcwp_get_customer_address_part($order_meta, '_country', $prefix));
$deliveryAddress->setBusiness($this->wcwp_get_customer_address_part($order_meta, '_company', $prefix));

if ($deliveryAddress->validate()) {
return $deliveryAddress;
} else {
Expand Down
67 changes: 33 additions & 34 deletions includes/wcwuunder-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ public static function wcwp_settings_tab() {

echo '<div style="background-color:#fff; border:1px solid #CCCCCC; margin-bottom:10px; padding:10px;">
<img src="' . Woocommerce_Wuunder::$plugin_url . 'assets/images/wuunder_logo.png" style="float:left; display:inline-block; padding:20px 30px 20px 20px; width:80px;">
<h4>Hallo, wij zijn Wuunder</h4>
<p>En we maken het versturen en ontvangen van documenten, pakketten en pallets makkelijk en voordelig. Met ons platform boek je een zending of retour via mobiel, Mac, PC en webshop plug-in. Wij vergelijken de bekende vervoerders, kiezen de beste prijs en halen de zending bij jou of iemand anders op. En daarna volg je de zending in het overzichtsscherm en klik je op de track & trace link voor meer details. Een foto sturen, vraag stellen of iets toelichten? Dat doe je via de Wuunder-chat. Wel zo persoonlijk.</p>
<p>Meer weten? Bezoek onze website <a href="http://www.wearewuunder.com/" target="_blank">www.wearewuunder.com</a> of stuur een e-mail naar <a href="mailto:[email protected]" target="_blank">[email protected]</a>.</p>
<h4>' . __('Hello, we are Wuunder', 'woocommerce-wuunder') . '</h4>
<p>' . __('and we make sending and receiving parcels easy and cheap. With our platform you can book via mobile, Mac, PC and webshop plug-ins.', 'woocommerce-wuunder') . '</p>
<p>' . __('Want to know more? Visit our website', 'woocommerce-wuunder') . ' <a href="http://www.wearewuunder.com/" target="_blank">www.wearewuunder.com</a> ' . __('or send an e-mail to', 'woocommerce-wuunder') . ' <a href="mailto:[email protected]" target="_blank">[email protected]</a>.</p>
</div>';

woocommerce_admin_fields( self::wcwp_get_settings() );
echo '<h1>Afhaaladressen</h1>';
echo '<p>Op onderstaande adressen worden je zendingen opgehaald of retouren weer afgeleverd. Gebruik de Bedrijfsnaam, contactpersoon en telefoonnummer waar de chauffeur van de vervoerder terecht kan met vragen. Naar het e-mail adres dat je hier gebruikt sturen we ook de verzendlabels mocht je deze niet willen downloaden via WooCommerce. Gebruik voor retouren de knop in het scherm met de “bestellingen”.</p>';
echo '<h1>' . __('Pickupaddresses', 'woocommerce-wuunder') . '</h1>';
echo '<p>' . __('On this address your shipment will be picked-up or send back to.', 'woocommerce-wuunder') . '</p>';
echo '<div class="row" style="overflow:hidden;">';
echo '<div class="address">';
woocommerce_admin_fields(self::wcwp_get_address() );
Expand All @@ -107,13 +107,13 @@ public static function wcwp_get_settings() {
$settings =
array(
'section_title' => array(
'name' => __( 'Wuunder instellingen', 'woocommerce-wuunder' ),
'name' => __( 'Wuunder settings', 'woocommerce-wuunder' ),
'type' => 'title',
'desc' => 'Algemene instellingen voor wuunder',
'desc' => __('General settings', 'woocommerce-wuunder' ),
'id' => 'wc_wuunder_section_title'
),
'api' => array(
'name' => __( 'Live / productie API Key', 'woocommerce-wuunder' ),
'name' => __( 'Live / production API Key', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_api'
),
Expand All @@ -125,10 +125,10 @@ public static function wcwp_get_settings() {
'api_status' => array(
'name' => __( 'Testmode', 'woocommerce-wuunder' ),
'type' => 'select',
'desc' => __( 'Ja = Test / staging, Nee = Live / productie', 'woocommerce-retailer' ),
'desc' => __( 'Yes = Test / staging, No = Live / production', 'woocommerce-wuunder' ),
'options' => array(
'staging' => __( 'Ja', 'woocommerce-wuunder' ),
'productie' => __( 'Nee', 'woocommerce-wuunder' )
'staging' => __( 'Yes', 'woocommerce-wuunder' ),
'productie' => __( 'No', 'woocommerce-wuunder' )
),
'id' => 'wc_wuunder_api_status'
),
Expand All @@ -139,7 +139,7 @@ public static function wcwp_get_settings() {
'id' => 'wc_wuunder_post_booking_status'
),
'default_image_base64' => array(
'name' => __( 'Standaard order image (base64 string), Leeg voor geen:', 'woocommerce-wuunder' ),
'name' => __( 'Default order image (base64 string), Empty for none:', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_default_image_base64'
),
Expand Down Expand Up @@ -171,46 +171,46 @@ public static function wcwp_get_mappings() {
'id' => 'wc_wuunder_section_title'
),
'mapping_method_1' => array(
'name' => __( 'Mapping verzendmethode #1', 'woocommerce-wuunder' ),
'name' => __( 'Mapping shippingmethod #1', 'woocommerce-wuunder' ),
'type' => 'select',
'options' => $options,
'id' => 'wc_wuunder_mapping_method_1'
),
'mapping_filter_1' => array(
'name' => __( 'Mapping filternaam #1', 'woocommerce-wuunder' ),
'name' => __( 'Mapping filtername #1', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_mapping_filter_1'
),
'mapping_method_2' => array(
'name' => __( 'Mapping verzendmethode #2', 'woocommerce-wuunder' ),
'name' => __( 'Mapping shippingmethod #2', 'woocommerce-wuunder' ),
'type' => 'select',
'options' => $options,
'id' => 'wc_wuunder_mapping_method_2'
),
'mapping_filter_2' => array(
'name' => __( 'Mapping filternaam #2', 'woocommerce-wuunder' ),
'name' => __( 'Mapping filtername #2', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_mapping_filter_2'
),
'mapping_method_3' => array(
'name' => __( 'Mapping verzendmethode #3', 'woocommerce-wuunder' ),
'name' => __( 'Mapping shippingmethod #3', 'woocommerce-wuunder' ),
'type' => 'select',
'options' => $options,
'id' => 'wc_wuunder_mapping_method_3'
),
'mapping_filter_3' => array(
'name' => __( 'Mapping filternaam #3', 'woocommerce-wuunder' ),
'name' => __( 'Mapping filtername #3', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_mapping_filter_3'
),
'mapping_method_4' => array(
'name' => __( 'Mapping verzendmethode #4', 'woocommerce-wuunder' ),
'name' => __( 'Mapping shippingmethod #4', 'woocommerce-wuunder' ),
'type' => 'select',
'options' => $options,
'id' => 'wc_wuunder_mapping_method_4'
),
'mapping_filter_4' => array(
'name' => __( 'Mapping filternaam #4', 'woocommerce-wuunder' ),
'name' => __( 'Mapping filtername #4', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_mapping_filter_4'
),
Expand All @@ -227,61 +227,60 @@ public static function wcwp_get_address() {
$settings =
array(
'section_title_1' => array(
'name' => __( 'Standaard afhaaladres', 'woocommerce-wuunder' ),
'name' => __( 'Default pickupaddress', 'woocommerce-wuunder' ),
'type' => 'title',
'desc' => 'Adres hoofdkantoor',
'id' => 'wc_wuunder_section_title'
),
'company' => array(
'name' => __( 'Bedrijfsnaam', 'woocommerce-wuunder' ),
'name' => __( 'Company name', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_company_name'
),
'firstname' => array(
'name' => __( 'Voornaam', 'woocommerce-wuunder' ),
'name' => __( 'Firstname', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_company_firstname'
),
'lastname' => array(
'name' => __( 'Achternaam', 'woocommerce-wuunder' ),
'name' => __( 'Lastname', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_company_lastname'
),
'email' => array(
'name' => __( 'Email', 'woocommerce-wuunder' ),
'name' => __( 'E-mail', 'woocommerce-wuunder' ),
'type' => 'email',
'id' => 'wc_wuunder_company_email'
),
'phone' => array(
'name' => __( 'Telefoonnummer', 'woocommerce-wuunder' ),
'name' => __( 'Phonenumber', 'woocommerce-wuunder' ),
'type' => 'text',
'desc' => __( 'Telefoonnummer inclusief landnummer, bv NL +31612345678', 'woocommerce-wuunder' ),
'desc' => __( 'Phonenumber including land prefix: NL +31612345678', 'woocommerce-wuunder' ),
'id' => 'wc_wuunder_company_phone'
),
'street' => array(
'name' => __( 'Straat', 'woocommerce-wuunder' ),
'name' => __( 'Streetname', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_company_street'
),
'housenumber' => array(
'name' => __( 'Huisnummer', 'woocommerce-wuunder' ),
'name' => __( 'Housenumber', 'woocommerce-wuunder' ),
'type' => 'number',
'id' => 'wc_wuunder_company_housenumber'
),
'postcode' => array(
'name' => __( 'Postcode', 'woocommerce-wuunder' ),
'name' => __( 'Zipcode', 'woocommerce-wuunder' ),
'type' => 'text',
'desc' => __( '1234AB', 'woocommerce-wuunder' ),
'id' => 'wc_wuunder_company_postode'
),
'city' => array(
'name' => __( 'Plaats', 'woocommerce-wuunder' ),
'name' => __( 'Locality', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_company_city'
),
'country' => array(
'name' => __( 'Landcode', 'woocommerce-wuunder' ),
'desc' => 'Landcode in ISO 3166-1 alpha-2 formaat, bv NL',
'name' => __( 'Landcode ISO-2', 'woocommerce-wuunder' ),
'desc' => __( 'Landcode in ISO 3166-1 alpha-2 format: NL', 'woocommerce-wuunder' ),
'type' => 'text',
'id' => 'wc_wuunder_company_country'
),
Expand Down
Binary file modified languages/woocommerce-wuunder-nl_NL.mo
Binary file not shown.
Loading

0 comments on commit 74a6b40

Please sign in to comment.