Code Monkey home page Code Monkey logo

magento2_customshipping's Introduction

NOTE: This repository has moved to https://github.com/magenizr/Magenizr_CustomShipping and will be continued there.

Magento2 CustomShipping

This Magento 2 module allows you to provide a custom shipping method in backend only, frontend only or both. With the Scheduler feature you can manage the availability automatically. In the following screenshots you can see an example Free - December Special for $0.00.

Magento2 CustomShipping - Intro

Magento2 CustomShipping - Backend - Frontend

Magento2 CustomShipping - Backend - Configuration

Magento2 CustomShipping - Backend - Configuration

Magento2 CustomShipping - Backend - Configuration

Magento2 CustomShipping - Backend - Configuration

Magento2 CustomShipping - Backend - Order

Installation (Composer)

  1. Add this extension to your repository composer config repositories.tobias-forkel/magento2-customshipping vcs https://github.com/tobias-forkel/Magento2_CustomShipping.git
  2. Update your composer.json composer require "tobias-forkel/magento2-customshipping":"1.2.1"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)              
Package operations: 1 install, 0 updates, 0 removals
  - Installing tobias-forkel/magento2-customshipping (1.2.1): Downloading (100%)         
Writing lock file
Generating autoload files

Installation (Manually)

  1. Pull the code.
  2. Copy the code in ./app/code/Forkel/CustomShipping/.
  3. Enable the module and clear static content.
php bin/magento module:enable Forkel_CustomShipping --clear-static-content
php bin/magento setup:upgrade

Features

  • The option Backend, Frontend or Backend / Frontend allows you hide or display the custom shipping method in frontend or backend.
  • The option Customer allows you to display the custom shipping method for logged in customers only.
  • With Scheduler you can manage the availability automatically by using the Start Date or End Date field.
  • Frequency allows you to enable the custom shipping method on specific weekdays only.
  • With Hide Other Shipping Methods you can disable other shipping methods if Custom Shipping is available.
  • Customizable Method Name and Method Title.
  • Customizable Price. Default is 0.00.

Usage

The functionality can be used in the backend section Stores > Configuration > Sales > Shipping Methods > Custom Shipping.

Support

If you have any issues with this extension, open an issue on Github. For a custom build, please contact me on http://www.tobiasforkel.de.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature.
  3. Commit your changes: git commit -am 'Add some feature'.
  4. Push to the branch: git push origin my-new-feature.
  5. Submit a pull request.

Follow me on GitHub and Twitter.

History

===== 1.2.1 =====

  • Fix composer.json

===== 1.2.0 =====

  • Added new feature Hide Other Shipping Methods that allows you to disable other shipping methods if Custom Shipping is available.
  • Code improvements

===== 1.1.0 =====

  • Added new feature Scheduler that allows you to enable and disable automatically. You can choose between Start Date and End Date, which you can combine with Frequency.
  • Code improvements

===== 1.0.1 =====

  • Code improvements in Model\Carrier\Custom
  • Added new option Customer that allows you to display the custom shipping method for logged in customers only.

===== 1.0.0 =====

  • Stable version of this module

License

OSL - Open Software Licence 3.0

magento2_customshipping's People

Contributors

tobias-forkel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

magento2_customshipping's Issues

Magento 2.2

Hi!

Do you know if this module works with Magento 2.2?

Get error in Custom 1-step Checkout

Hi,

I tried this extension with our one step checkout Klarna (https://nordicwebteam.se/magento-2-extensions/klarna-checkout-magento-2.html)
This is an extension that a lot of stores uses in the nordic countries.
It's a free extension, and you can use it with test credentials.

In exception.log file I get:
[2017-11-28 08:28:32] main.ERROR: Magento\Framework\Exception\LocalizedException: Quote was updated, please review it (check shipping amount, products) in /home/smarthem/www/magento2/app/code/NWT/KCO/Model/Checkout.php:582

Feature Request

Hi,
Looks like a great extension!
It would be a great to schedule the shipping method. (Start/end)

isAvailable() when admin is logged to backend

Hi,
I am using the plugin to create backend orders, using a custom made plugin.

The method Config::isAvailable() return false when admin is logged to backend and tries to create an order.

I added
\Magento\Backend\Model\Auth\Session $authSession
to __construct(...)

and changed:

protected function isAdmin()
{
return 'adminhtml' === $this->_session->getAreaCode() || $this->_authSession->getUser()->getEmail();
}

this is the full code

available at: https://pastebin.com/nCPm0wzc

_timezone = $timezone; $this->_session = $session; $this->_authSession = $authSession; $this->_scopeConfig = $scopeConfig; } /** * Get module configuration values from core_config_data * * @param $setting * @return mixed */ public function getConfig($setting) { return $this->_scopeConfig->getValue( $this->_tab . '/forkel_customshipping/' . $setting, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } /** * Get different values from core_config_data and decide if custom shipping method is available. * * @return boolean */ public function isAvailable() { $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/mylog.log' ); $this->logger = new \Zend\Log\Logger(); $this->logger->addWriter($writer); $this->logger->info(__METHOD__ . " begin "); $this->logger->info(__METHOD__ . " active ". $this->getConfig('active')); $this->logger->info(__METHOD__ . " availability ". $this->getConfig('availability')); $this->logger->info(__METHOD__ . " isAdmin ". $this->isAdmin()); $this->logger->info(__METHOD__ . " _session->getAreaCode ". $this->_session->getAreaCode()); $this->logger->info(__METHOD__ . " _authSession ". $this->_authSession->getUser()->getEmail()); $date_current = strtotime($this->_timezone->formatDate()); $date_start = strtotime($this->getConfig('date_start')); $date_end = strtotime($this->getConfig('date_end')); $frequency = $this->getConfig('frequency'); $day = strtolower(date('D', $date_current)); /** * Check if shipping method is actually enabled */ if (!$this->getConfig('active')) { return false; } /** * Check if shipping method should be available for logged in users only */ if ($this->getConfig('customer') && !$this->isCustomerLoggedIn()) { return false; } /** * Check if shipping method should be visible in backend, frontend or both */ if ( !($this->getConfig('availability') == 'backend' && $this->isAdmin()) || ($this->getConfig('availability') == 'frontend' && !$this->isAdmin()) ) { $this->logger->info(__METHOD__ . " bad backend/frontend + isAdmin "); return false; } /** * Check if scheduler is enabled */ if ($this->getConfig('scheduler_enabled')) { /** * Check if shipping method should be visible at current name of day */ if (strpos($frequency, $day) === false) { return false; } /** * Check if start date is in range */ if ($date_start && $date_start > $date_current) { return false; } /** * Check if start end is in range */ if ($date_end && $date_end < $date_current) { return false; } } $this->logger->info(__METHOD__ . " is available "); return true; } /** * Check if current user logged in as admin * * @return bool */ protected function isAdmin() { return 'adminhtml' === $this->_session->getAreaCode() || $this->_authSession->getUser()->getEmail(); } /** * Check if current user logged in * * @return bool */ protected function isCustomerLoggedIn() { return $this->_session->isLoggedIn(); } }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.