Skip to content

Commit

Permalink
Merge pull request #66 from YotpoLtd/YES_27_failed_to_load_bottom_line
Browse files Browse the repository at this point in the history
Yes 27 failed to load bottom line
  • Loading branch information
Alex Berenshtein committed Nov 29, 2017
2 parents 31352f3 + 4b9c36b commit 6bc7509
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 6 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.idea
.DS_Store
nbproject/project.xml
nbproject/project.properties
nbproject/private/private.properties
nbproject/*.*
nbproject/
7 changes: 7 additions & 0 deletions Block/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Config
const YOTPO_SECRET = 'yotpo/settings/secret';
const YOTPO_WIDGET_ENABLED = 'yotpo/settings/widget_enabled';
const YOTPO_BOTTOMLINE_ENABLED = 'yotpo/settings/bottomline_enabled';
const YOTPO_BOTTOMLINE_QNA_ENABLED = 'yotpo/settings/qna_enabled';

const YOTPO_CUSTOM_ORDER_STATUS = 'yotpo/settings/custom_order_status';

public function __construct(
Expand Down Expand Up @@ -45,6 +47,11 @@ public function isBottomlineEnabled()
{
return (bool)$this->_scopeConfig->getValue(self::YOTPO_BOTTOMLINE_ENABLED, ScopeInterface::SCOPE_STORE);
}

public function isBottomlineQnaEnabled()
{
return (bool)$this->_scopeConfig->getValue(self::YOTPO_BOTTOMLINE_QNA_ENABLED, ScopeInterface::SCOPE_STORE);
}

public function isAppKeyAndSecretSet($storeId = null)
{
Expand Down
5 changes: 5 additions & 0 deletions Block/Yotpo.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public function isRenderBottomline()
{
return $this->_config->isBottomlineEnabled();
}

public function isRenderBottomlineQna()
{
return $this->_config->isBottomlineQnaEnabled();
}

public function getProductImageUrl()
{
Expand Down
2 changes: 1 addition & 1 deletion Helper/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ public function massCreatePurchases($orders, $token, $storeId)
$data['orders'] = $orders;
return $this->createApiPost("apps/".$appKey."/purchases/mass_create", $data);
}
}
}
11 changes: 10 additions & 1 deletion Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ public function showWidget($thisObj, $product = null, $print=true)
return $this->renderYotpoProductBlock($thisObj, 'widget_div', $product, $print);
}


public function showBottomline($thisObj, $product = null, $print=true)
{
return $this->renderYotpoProductBlock($thisObj, 'bottomline', $product, $print);
}

public function showQABottomline($thisObj, $product = null, $print=true)
{
return $this->renderYotpoProductBlock($thisObj, 'yotpo-qa-bottomline', $product, $print);
}

public function showQuestions($thisObj, $product = null, $print=true)
{
return $this->renderYotpoProductBlock($thisObj, 'yotpo-questions', $product, $print);
}

private function renderYotpoProductBlock($thisObj, $blockName, $product = null, $print=true)
{
Expand Down
10 changes: 10 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@
<br/><a href="https://support.yotpo.com/en/article/magento-2-installing-yotpo#to-insert-the-star-rating-manually-on-your-catalog-page" target="_blank" title="advanced-cusomization-guide">advanced customizations guide</a>]]>
</comment>
</field>
<field id="qna_enabled" translate="label" type="select" sortOrder="5" showInDefault="0" showInWebsite="0" showInStore="1">
<label>Show bottomline Questions Answers</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<backend_model>Yotpo\Yotpo\Model\Config\Backend\ValidateSettings</backend_model>
<comment>
<![CDATA[
By choosing not to use the deafult position, you'll need to follow the instructions in the
<br/><a href="http://support.yotpo.com/entries/22635391-advanced-magento-features?utm_source=customers_magento_admin&utm_medium=link&utm_campaign=magento_admin_advanced_magento_features" target="_blank" title="advanced-cusomization-guide">advanced customizations guide</a>]]>
</comment>
</field>
<field id="custom_order_status" translate="label" type="multiselect" sortOrder="4" showInDefault="0" showInWebsite="0" showInStore="1">
<label>Export Order After Purchase</label>
<source_model>Magento\Sales\Model\ResourceModel\Order\Status\Collection</source_model>
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

<referenceContainer name="product.info.main">
<block class="Yotpo\Yotpo\Block\Yotpo" name="bottomline" as="other" template="bottomline.phtml" before="product.info.addto"/>
<block class="Yotpo\Yotpo\Block\Yotpo" name="yotpo-qa-bottomline" as="other" template="yotpo-qa-bottomline.phtml" before="product.info.addto"/>
<block class="Yotpo\Yotpo\Block\Yotpo" name="yotpo-questions" as="other" template="yotpo-questions.phtml" before="product.info.addto"/>

</referenceContainer>

<!-- Add yotpo widget div to product page -->
Expand Down
16 changes: 15 additions & 1 deletion view/frontend/templates/bottomline.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<?php if($this->isRenderBottomlineQna()){ ?>
<style>
.yotpo-icon-double-bubble, .yotpo-stars { margin: 0 5px 0 0 !important; }
div.yotpo.bottomLine { display: inline-block; margin: 0 10px 1px 0;}
.thumbnail .yotpo a { display: inline-block; }
div.yotpo.QABottomLine { display: inline-block; }
</style>
<?php } ?>

<?php if( $this->isRenderBottomline()) { ?>
<div class="yotpo bottomLine"
data-product-id="<?php echo $this->getProductId() ?>"
data-url="<?php echo $this->getProductUrl() ?>">
</div>
<?php } ?>
<?php } ?>

<?php
if($this->isRenderBottomlineQna()){
$this->helper('Yotpo\Yotpo\Helper\Data')->showQABottomline($this);
} ?>
1 change: 1 addition & 0 deletions view/frontend/templates/qna.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php $this->helper('Yotpo\Yotpo\Helper\Data')->showQna($this, $_product); ?>
4 changes: 4 additions & 0 deletions view/frontend/templates/yotpo-qa-bottomline.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="yotpo QABottomLine"
data-appkey="<?php echo $this->getAppKey() ?>"
data-product-id="<?php echo $this->getProductId() ?>">
</div>

0 comments on commit 6bc7509

Please sign in to comment.