Skip to content

Commit

Permalink
Merge pull request #5 from vippsas/publication-1.2.2
Browse files Browse the repository at this point in the history
Publication 1.2.2
 - fixed issue with broken checkout page
 - added new email template for customer account confirmation
  • Loading branch information
ed007m authored Feb 17, 2020
2 parents af3a16f + 7801908 commit fe2dc2f
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 3 deletions.
108 changes: 108 additions & 0 deletions Observer/ConfigObserver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php
/**
* Copyright 2019 Vipps
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE
*/

declare(strict_types=1);

namespace Vipps\Login\Observer;

use Magento\Customer\Model\EmailNotification;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Config\App\Config\Type\System as SystemConfig;
use Vipps\Login\Model\ConfigInterface;

/**
* Class ConfigObserver
* @package Vipps\Login\Observer
*/
class ConfigObserver implements ObserverInterface
{
const VIPPS_TEMPLATE_ID = 'vipps_login_create_account_email_no_password_template';

/**
* @var ConfigInterface
*/
private $config;

/**
* @var WriterInterface
*/
private $configWriter;

/**
* @var SystemConfig
*/
private $systemConfig;

/**
* ConfigObserver constructor.
*
* @param SystemConfig $systemConfig
* @param ConfigInterface $config
* @param WriterInterface $configWriter
*/
public function __construct(
SystemConfig $systemConfig,
ConfigInterface $config,
WriterInterface $configWriter
) {
$this->config = $config;
$this->configWriter = $configWriter;
$this->systemConfig = $systemConfig;
}

/**
* {@inheritdoc}
*
* @param Observer $observer
*/
public function execute(Observer $observer)
{
$storeId = $observer->getStore();
$websiteId = $observer->getWebsite();

if ($storeId) {
$scope = 'stores';
$scopeId = (int) $storeId;
} elseif ($websiteId) {
$scope = 'websites';
$scopeId = (int) $websiteId;
$storeId = 0;
} else {
$scope = 'default';
$scopeId = 0;
$storeId = 0;
}

if ($this->config->isEnabled($storeId)) {
$this->configWriter->save(
EmailNotification::XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE,
self::VIPPS_TEMPLATE_ID,
$scope,
$scopeId
);
} else {
$this->configWriter->delete(
EmailNotification::XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE,
$scope,
$scopeId
);
}

$this->systemConfig->clean();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"psr/log": "~1.0"
},
"type": "magento2-module",
"version": "1.2.1",
"version": "1.2.2",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
20 changes: 20 additions & 0 deletions etc/adminhtml/events.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!--
~ Copyright 2018 Vipps
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
~ documentation files (the "Software"), to deal in the Software without restriction, including without limitation
~ the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
~ and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
~ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
~ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
~ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
~ IN THE SOFTWARE
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="admin_system_config_changed_section_vipps">
<observer name="vipps_login_admin_system_config_changed_section_general" instance="Vipps\Login\Observer\ConfigObserver"/>
</event>
</config>
7 changes: 7 additions & 0 deletions etc/email_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@
type="html"
module="Vipps_Login"
area="frontend" />

<template id="vipps_login_create_account_email_no_password_template"
label="New Account Without Password"
file="account_new_no_password.html"
type="html"
module="Vipps_Login"
area="frontend"/>
</config>
2 changes: 2 additions & 0 deletions i18n/nb_NO.csv
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ Debug,Feilsøk
"Confirm my email address","Bekreft e-postadressen min"
"Check your inbox","Sjekk innboksen din"
"User cancelled the login", "Bruker avbrøt innloggingen"
"You can sign in using", "Du kan logge inne med"
"or log in to our site and set a password using this <a href='%create_password_url'>link</a>.", "eller logge inn på kontoen din og sette et passord med denne <a href='%create_password_url'>linken</a>."
59 changes: 59 additions & 0 deletions view/frontend/email/account_new_no_password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!--
/**
* Copyright 2019 Vipps
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
-->
<!--@subject {{trans "Welcome to %store_name" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
"var this.getUrl($store, 'vipps/login/index/')":"Vipps Login URL",
"var customer.email":"Customer Email",
"var customer.name":"Customer Name"
} @-->
{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$customer.name}}</p>
<p>{{trans "Welcome to %store_name." store_name=$store.getFrontendName()}}</p>

<div class="login-vipps">
{{trans 'You can sign in using'|raw}}
<br>
<form action="{{var this.getUrl($store, 'vipps/login/index/',[_nosid:1])}}" method="post" target="_blank" style="margin-top: 5px;">
<button type="submit" class="action create primary vipps-btn">
{{trans 'Sign in with'|raw}}
<span class="icon-vipps"
style="background: url({{view url='Vipps_Login/images/vipps-white-logo.png'}}) left center no-repeat;">
</span>
</button>
</form>
</div>
<br>
<p>
{{trans "or log in to our site and set a password using this <a href='%create_password_url'>link</a>."
create_password_url="$this.getUrl($store,'customer/account/createPassword/',[_query:[id:$customer.id,token:$customer.rp_token],_nosid:1])"
|raw}}
</p>

<ul>
<li><strong>{{trans "Email:"}}</strong> {{var customer.email}}</li>
</ul>
<p>{{trans "When you sign in to your account, you will be able to:"}}</p>
<ul>
<li>{{trans "Proceed through checkout faster"}}</li>
<li>{{trans "Check the status of orders"}}</li>
<li>{{trans "View past orders"}}</li>
<li>{{trans "Store alternative addresses (for shipping to multiple family members and friends)"}}</li>
</ul>

{{template config_path="design/email/footer_template"}}
3 changes: 1 addition & 2 deletions view/frontend/layout/checkout_index_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
~ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
~ IN THE SOFTWARE
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="klarnacheckout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="checkout_index_index"/>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.root">
<arguments>
Expand Down
44 changes: 44 additions & 0 deletions view/frontend/web/css/source/_email.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2018 Vipps
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE
*/
@import "module/_variables.less";


.login-vipps {
margin-top: 10px;

.vipps-btn {
display: flex;
background: @vipps__color;
color: @color__white;
text-transform: none;
font-family: 'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;
font-weight: 600;
padding: 15px 25px;
border-radius: 25px;
border: 0;
cursor: pointer;
}
}

.vipps-btn {
.icon-vipps {
display: inline-block;
background-size: 55px 14px;
padding-left: 62px;
height: 15px;
margin-left: 10px;

}
}

0 comments on commit fe2dc2f

Please sign in to comment.