Skip to content

Commit

Permalink
Merge pull request #38 from wuunder/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
timoj authored Dec 16, 2019
2 parents ea6b54c + f53de5f commit 9644b49
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 324 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Released

## [2.7.10](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.10) - 2019-12-11

### Added
- Wuunder shipping methods are taxable
- 2nd address line is send to wuunder with booking

### Fixed
- Parcelshop error messages in checkout
- Fixed sending company name in delivery address

### Removed
- Legacy setting google api key


## [2.7.9](https://github.com/kabisa/wuunder-webshopplugin-woocommerce/tag/2.7.9) - 2019-11-12

### Added
Expand Down
2 changes: 1 addition & 1 deletion includes/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function wcwp_check_parcelshop_selection()
wc_add_notice(__('Kies eerst een <strong>parcelshop</strong>'), 'error');
}

if (!isset($_POST['shipping_country']) || $_POST['shipping_country'] != $_POST['parcelshop_country']) {
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');
}
}
Expand Down
104 changes: 64 additions & 40 deletions includes/wcwuunder-DPD-standard-shipping.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

if ( !defined( 'WPINC' ) ) {
if (!defined('WPINC')) {
die;
}

if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins') ) ) ) {
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {

function WC_wuunder_DPD_standard_method()
{
if ( !class_exists( 'WC_wuunder_DPD_standard' ) ) {
if (!class_exists('WC_wuunder_DPD_standard')) {
class WC_wuunder_DPD_standard extends WC_Shipping_Method
{
/**
Expand All @@ -17,11 +17,12 @@ class WC_wuunder_DPD_standard extends WC_Shipping_Method
* @access public
* @return void
*/
public function __construct($instance_id = 0) {
public function __construct($instance_id = 0)
{
$this->id = 'wuunder_DPD_standard';
$this->instance_id = absint( $instance_id );
$this->method_title = __( 'Aflevering op huisadres via DPD' );
$this->method_description = __( 'Gratis verzending vanaf ingestelde waarde per zone' );
$this->instance_id = absint($instance_id);
$this->method_title = __('Aflevering op huisadres via DPD');
$this->method_description = __('Gratis verzending vanaf ingestelde waarde per zone');
$this->enabled = 'yes';
$this->supports = array(
'shipping-zones',
Expand All @@ -37,42 +38,55 @@ public function __construct($instance_id = 0) {
* @access public
* @return void
*/
function init() {
function init()
{
// Load the settings API
$this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings
$this->init_settings(); // This is part of the settings API. Loads settings you previously init.

// These are the options set by the user
$this->cost = $this->get_option( 'cost' );
$this->carriers = $this->get_option( 'select_carriers');
$this->title = $this->get_option( 'title' );
$this->cost = $this->get_option('cost');
$this->carriers = $this->get_option('select_carriers');
$this->title = $this->get_option('title');
$this->tax_status = $this->get_option('tax_status');
// Save settings in admin if you have any defined
add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options'));
}

function init_form_fields() {
function init_form_fields()
{

$this->instance_form_fields = array(
'title' => array(
'title' => __( 'Naam van de verzendmethode', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Dit stelt de naam van de verzendmethode in op de check-out pagina.', 'woocommerce' ),
'default' => __( 'Aflevering op huisadres via DPD' ),
'desc_tip' => true
'title' => __('Naam van de verzendmethode', 'woocommerce'),
'type' => 'text',
'description' => __('Dit stelt de naam van de verzendmethode in op de check-out pagina.', 'woocommerce'),
'default' => __('Aflevering op huisadres via DPD'),
'desc_tip' => true
),
'cost' => array(
'title' => __( 'Kosten', 'woocommerce' ),
'type' => 'number',
'description' => __( 'Kosten voor gebruik van de verzendmethode', 'woocommerce', 'woocommerce' ),
'default' => 3.50,
'desc_tip' => true
'cost' => array(
'title' => __('Kosten', 'woocommerce'),
'type' => 'number',
'description' => __('Kosten voor gebruik van de verzendmethode', 'woocommerce', 'woocommerce'),
'default' => 3.50,
'desc_tip' => true
),
'free_from' => array(
'title' => __( 'Gratis verzending vanaf', 'woocommerce' ),
'type' => 'number',
'description' => __( 'Vanaf welk bestelbedrag is de verzending gratis. Stel 0 in voor nooit.', 'woocommerce' ),
'default' => 50.00,
'desc_tip' => true
'title' => __('Gratis verzending vanaf', 'woocommerce'),
'type' => 'number',
'description' => __('Vanaf welk bestelbedrag is de verzending gratis. Stel 0 in voor nooit.', 'woocommerce'),
'default' => 50.00,
'desc_tip' => true
),
'tax_status' => array(
'title' => __('Tax status', 'woocommerce'),
'type' => 'select',
'class' => 'wc-enhanced-select',
'default' => 'taxable',
'options' => array(
'taxable' => __('Taxable', 'woocommerce'),
'none' => _x('None', 'Tax status', 'woocommerce'),
),
),
);

Expand All @@ -85,32 +99,42 @@ function init_form_fields() {
* @param mixed $package
* @return void
*/
public function calculate_shipping( $package = array() ) {
$cost = $this->get_option( 'cost' );
if ( $this->get_option( 'free_from' ) > 0 && $package['contents_cost'] >= $this->get_option( 'free_from' ) ) {
public function calculate_shipping($package = array())
{
$cost = $this->get_option('cost');
if ($this->get_option('free_from') > 0 && $package['contents_cost'] >= $this->get_option('free_from')) {
$cost = 0;
}

if (!isset($this->tax_status) || $this->tax_status == 'none') {
$tax = false;
} else {
$tax = '';
}

$rate = array(
'id' => $this->id,
'label' => $this->title,
'cost' => $cost,
'calc_tax' => 'per_item'
'id' => $this->id,
'label' => $this->title,
'cost' => $cost,
'taxes' => $tax,
'calc_tax' => 'per_order'
);

// Register the rate
$this->add_rate( $rate );
$this->add_rate($rate);
}

}
}
}

add_action( 'woocommerce_shipping_init', 'WC_wuunder_DPD_standard_method' );
add_action('woocommerce_shipping_init', 'WC_wuunder_DPD_standard_method');

function wuunder_DPD_standard_shipping( $methods ) {
function wuunder_DPD_standard_shipping($methods)
{
$methods['wuunder_DPD_standard'] = 'WC_wuunder_DPD_standard';
return $methods;
}

add_filter( 'woocommerce_shipping_methods', 'wuunder_DPD_standard_shipping' );
add_filter('woocommerce_shipping_methods', 'wuunder_DPD_standard_shipping');
}
Loading

0 comments on commit 9644b49

Please sign in to comment.