Skip to content

Commit

Permalink
Added changes for 2.2 #1432
Browse files Browse the repository at this point in the history
  • Loading branch information
federicocanedo committed Jun 22, 2022
1 parent 7b357bf commit ebe309e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
38 changes: 38 additions & 0 deletions Block/Adminhtml/System/Config/CreateAbandonedCart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Ebizmarts_MailChimp Magento JS component
*
* @category Ebizmarts
* @package Ebizmarts_MailChimp
* @author Ebizmarts Team <info@ebizmarts.com>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config;

class CreateAbandonedCart extends \Magento\Config\Block\System\Config\Form\Field
{
protected $_template = 'system/config/create_abandonedcart_automation.phtml';

private $_url = "https://admin.mailchimp.com/#/create-campaign/explore/abandonedCart";

protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$originalData = $element->getOriginalData();

$label = $originalData['button_label'];

$this->addData([
'button_label' => __($label),
'button_url' => $this->authorizeRequestUrl(),
'html_id' => $element->getHtmlId(),
]);
return parent::_toHtml();
;
}
public function authorizeRequestUrl()
{
return $this->_url;
}
}
10 changes: 9 additions & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="firstdate" translate="label" type="date" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="firstdate" translate="label" type="date" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>First Date</label>
<frontend_model>Ebizmarts\MailChimp\Block\Adminhtml\System\Config\Date</frontend_model>
<depends>
Expand All @@ -243,6 +243,14 @@
<field id="*/*/active">1</field>
</depends>
</field>
<field id="create_abandonedcart_automation" translate="label" sortOrder="60" showInDefault="1" showInStore="1" showInWebsite="1">
<attribute type="button_label">Create Abandoned Cart Automation</attribute>
<frontend_model>Ebizmarts\MailChimp\Block\Adminhtml\System\Config\CreateAbandonedCart</frontend_model>
<comment>Must be logged in to MailChimp's website previously to see the automation wizard, re-open if not</comment>
<depends>
<field id="*/*/active">1</field>
</depends>
</field>
</group>
</section>
</system>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="actions actions-get-apikey">
<button onclick="javascript:window.open('<?php echo $this->authorizeRequestUrl() ?>', 'apiwizard','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=800, height=600'); return false;" class="action-get-apikey" type="button" id="<?php echo $block->getHtmlId() ?>">
<span><?php echo $block->escapeHtml($block->getButtonLabel()) ?></span>
</button>
</div>

0 comments on commit ebe309e

Please sign in to comment.