Skip to content

Commit 5b99d44

Browse files
committed
Improved naming
1 parent a6e04f7 commit 5b99d44

File tree

10 files changed

+40
-49
lines changed

10 files changed

+40
-49
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Picqer
3+
Copyright (c) 2019 Picqer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Model/Sales/Active.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Picqer\Webhooks\Model\Sales;
3+
namespace Picqer\Magento2\Model\Sales;
44

55
class Active implements \Magento\Framework\Option\ArrayInterface
66
{

Observer/SendWebhook.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Picqer\Webhooks\Observer;
3+
namespace Picqer\Magento2\Observer;
44

55
use Magento\Framework\Event\ObserverInterface;
66

@@ -19,22 +19,25 @@ public function __construct(
1919

2020
public function execute(\Magento\Framework\Event\Observer $observer)
2121
{
22-
$active = $this->_scopeConfig->getValue('picqer_webhook_options/general_settings/active');
23-
if ($active != 1) {
22+
$active = $this->_scopeConfig->getValue('picqer_integration_options/webhook_settings/active');
23+
if ((int)$active !== 1) {
2424
return;
2525
}
2626

27-
$magentoKey = $this->_scopeConfig->getValue('picqer_webhook_options/general_settings/connection_key');
28-
$domain = $this->_scopeConfig->getValue('picqer_webhook_options/general_settings/picqer_domain');
27+
$subDomain = $this->_scopeConfig->getValue('picqer_integration_options/webhook_settings/picqer_subdomain');
28+
$magentoKey = $this->_scopeConfig->getValue('picqer_integration_options/webhook_settings/connection_key');
29+
30+
if (empty($subDomain) || empty($magentoKey)) {
31+
return; // Not fully configured
32+
}
2933

3034
$order = $observer->getEvent()->getOrder();
3135

3236
$orderData = [];
3337
$orderData['increment_id'] = $order->getIncrementId();
3438
$orderData['picqer_magento_key'] = $magentoKey;
35-
$orderData = json_encode($orderData);
3639

3740
$this->_curl->addHeader("Content-Type", "application/json");
38-
$this->_curl->post('https://' . $domain . '.picqer.com/webshops/magento2/orderPush/' . $magentoKey, $orderData);
41+
$this->_curl->post('https://' . $subDomain . '.picqer.com/webshops/magento2/orderPush/' . $magentoKey, json_encode($orderData));
3942
}
4043
}

README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1-
### Picqer Extended Integration for Magento 2
2-
----
3-
4-
1+
# Picqer Extended Integration for Magento 2
52
Magento 2 Extensions for Picqer.
6-
7-
8-
----
9-
### Installation:
10-
3+
4+
## Installation:
115
This project can easily be installed through Composer.
126

137
`composer require picqer/magento2-plugin`
148

15-
### Activate module
16-
9+
## Activate module
1710
1. Log onto your Magento 2 admin account and navigate to Stores > Configuration > Picqer > Webhooks
1811
2. Fill out the general configuration information:
1912
+ Active: Yes
13+
+ Picqer Subdomain: is the prefix of your domain name. If you log on to 'my-shop.picqer.com', then fill in 'my-shop'.
2014
+ Connection Key: can be found in Picqer > Settings > Webshops > Magento shop. Copy and paste in this field.
21-
+ Picqer Domain: is the prefix of your domain name. If you log on to 'test.picqer.com', then fill in 'test'.
2215

23-
Orders will now be pushed to Picqer immediately.
24-
16+
Orders updates will now be pushed to Picqer immediately.

composer.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,23 @@
77
"picqer",
88
"magento2"
99
],
10+
"homepage": "https://github.com/picqer/magento2-plugin",
1011
"license": "MIT",
1112
"require": {
12-
"php": ">=5.6.0"
13+
"php": ">=5.6.0",
14+
"ext-curl": "*",
15+
"ext-json": "*"
1316
},
14-
"repositories": [
15-
{
16-
"type": "git",
17-
"url": "https://github.com/picqer/magento2-plugin"
18-
}
19-
],
2017
"authors": [
2118
{
22-
"name": "Casper Bakker",
19+
"name": "Anna van Brecht",
2320
"email": "[email protected]"
2421
}
2522
],
2623
"autoload": {
2724
"files": ["registration.php"],
2825
"psr-4": {
29-
"Picqer\\Webhooks\\" : ""
26+
"Picqer\\Magento2\\" : ""
3027
}
3128
}
3229
}

etc/adminhtml/system.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
<tab id="picqer" translate="label" sortOrder="10">
55
<label>Picqer</label>
66
</tab>
7-
<section id="picqer_webhook_options" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
7+
<section id="picqer_integration_options" translate="label" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
88
<class>separator-top</class>
9-
<label>Webhooks</label>
9+
<label>Integration</label>
1010
<tab>picqer</tab>
11-
<resource>Picqer_Webhooks::webhooks_config</resource>
12-
<group id="general_settings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
11+
<resource>Picqer_Integration::webhooks_config</resource>
12+
<group id="webhook_settings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
1313
<label>General Configuration</label>
14-
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
14+
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
1515
<label>Active</label>
16-
<source_model>Picqer\Webhooks\Model\Sales\Active</source_model>
16+
<source_model>Picqer\Magento2\Model\Sales\Active</source_model>
1717
</field>
18-
<field id="connection_key" translate="label" type="text" sortOrder="10" showInDefault="3" showInWebsite="0" showInStore="0">
19-
<label>Connection Key</label>
18+
<field id="picqer_subdomain" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
19+
<label>Picqer subdomain</label>
2020
</field>
21-
<field id="picqer_domain" translate="label" type="text" sortOrder="10" showInDefault="4" showInWebsite="0" showInStore="0">
22-
<label>Picqer Domain</label>
21+
<field id="connection_key" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
22+
<label>Connection key</label>
2323
</field>
2424
</group>
2525
</section>

etc/config.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?xml version="1.0"?>
22
<config>
33
<default>
4-
<picqer_webhook_options>
5-
<general_settings>
6-
</general_settings>
7-
</picqer_webhook_options>
4+
<picqer_integration_options>
5+
<webhook_settings />
6+
</picqer_integration_options>
87
</default>
98
</config>

etc/events.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
33
<event name="sales_order_save_after">
4-
<observer name="picqer_webhooks_sales_order_save_after" instance="Picqer\Webhooks\Observer\SendWebhook" />
4+
<observer name="picqer_webhooks_sales_order_save_after" instance="Picqer\Magento2\Observer\SendWebhook" />
55
</event>
66
</config>

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Picqer_Webhooks" setup_version="1.0.0">
3+
<module name="Picqer_Integration" setup_version="1.0.0">
44
<sequence>
55
<module name="Magento_Webapi" />
66
</sequence>

registration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
use \Magento\Framework\Component\ComponentRegistrar;
44

5-
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Picqer_Webhooks', __DIR__);
5+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Picqer_Integration', __DIR__);

0 commit comments

Comments
 (0)