Magento 2 : Google Customer Reviews
How will final result should looks like for this implementation.
Thank you
file location: /vendor/magento/module-checkout/Controller/Onepage/Success.php
below is my default Success.php for Magento 2.1
> <?php /** * * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ namespace MagentoCheckoutControllerOnepage;
class Success extends MagentoCheckoutControllerOnepage {
/**
* Order success action
*
* @return MagentoFrameworkControllerResultInterface
*/
public function execute()
{
$session = $this->getOnepage()->getCheckout();
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid()) {
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
}
$session->clearQuote();
//@todo: Refactor it to match CQRS
$resultPage = $this->resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$session->getLastOrderId()]]
);
return $resultPage;
} }
............................ where do i paste this code on Success.php
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
magento2 review code-generation
add a comment |
How will final result should looks like for this implementation.
Thank you
file location: /vendor/magento/module-checkout/Controller/Onepage/Success.php
below is my default Success.php for Magento 2.1
> <?php /** * * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ namespace MagentoCheckoutControllerOnepage;
class Success extends MagentoCheckoutControllerOnepage {
/**
* Order success action
*
* @return MagentoFrameworkControllerResultInterface
*/
public function execute()
{
$session = $this->getOnepage()->getCheckout();
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid()) {
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
}
$session->clearQuote();
//@todo: Refactor it to match CQRS
$resultPage = $this->resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$session->getLastOrderId()]]
);
return $resultPage;
} }
............................ where do i paste this code on Success.php
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
magento2 review code-generation
add a comment |
How will final result should looks like for this implementation.
Thank you
file location: /vendor/magento/module-checkout/Controller/Onepage/Success.php
below is my default Success.php for Magento 2.1
> <?php /** * * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ namespace MagentoCheckoutControllerOnepage;
class Success extends MagentoCheckoutControllerOnepage {
/**
* Order success action
*
* @return MagentoFrameworkControllerResultInterface
*/
public function execute()
{
$session = $this->getOnepage()->getCheckout();
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid()) {
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
}
$session->clearQuote();
//@todo: Refactor it to match CQRS
$resultPage = $this->resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$session->getLastOrderId()]]
);
return $resultPage;
} }
............................ where do i paste this code on Success.php
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
magento2 review code-generation
How will final result should looks like for this implementation.
Thank you
file location: /vendor/magento/module-checkout/Controller/Onepage/Success.php
below is my default Success.php for Magento 2.1
> <?php /** * * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ namespace MagentoCheckoutControllerOnepage;
class Success extends MagentoCheckoutControllerOnepage {
/**
* Order success action
*
* @return MagentoFrameworkControllerResultInterface
*/
public function execute()
{
$session = $this->getOnepage()->getCheckout();
if (!$this->_objectManager->get('MagentoCheckoutModelSessionSuccessValidator')->isValid()) {
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
}
$session->clearQuote();
//@todo: Refactor it to match CQRS
$resultPage = $this->resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$session->getLastOrderId()]]
);
return $resultPage;
} }
............................ where do i paste this code on Success.php
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
magento2 review code-generation
magento2 review code-generation
edited Apr 5 '17 at 6:08
Dhiren Vasoya
4,38751843
4,38751843
asked Apr 4 '17 at 17:03
rogerroger
146215
146215
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
I think you would use the file located at or whatever the vendor/template you use
vendor/magento/module-checkout/view/frontend/templates/success.phtml
In which case, you would put the google code after the last in the success.phtml file
add a comment |
You need to put this code in vendor/magento/module-checkout/view/frontend/templates/success.phtml
.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var $block MagentoCheckoutBlockOnepageSuccess */ ?>
<div class="checkout-success">
<?php if ($block->getOrderId()):?>
<?php if ($block->getCanViewOrder()) :?>
<p><?= __('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?></p>
<?php else :?>
<p><?= __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p>
<?php endif;?>
<p><?= /* @escapeNotVerified */ __('We'll email you an order confirmation with details and tracking info.') ?></p>
<?php endif;?>
<?= $block->getAdditionalInfoHtml() ?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?= /* @escapeNotVerified */ $block->getContinueUrl() ?>"><span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span></a>
</div>
</div>
</div>
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
add a comment |
app/design/frontend/magento/theme/Magento_Checkout/templates/success.phtml
Add this script
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": xxxxxxxxx,
"order_id": "<?php echo $orderData->getIncrementId() ?>",
"email": "<?php echo $orderData->getCustomerEmail() ?>",
"delivery_country": "<?php echo $orderData->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
This looks like code for Magento 1, not Magento 2.
– Steve Robbins
Nov 14 '17 at 19:27
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f167643%2fmagento-2-google-customer-reviews%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you would use the file located at or whatever the vendor/template you use
vendor/magento/module-checkout/view/frontend/templates/success.phtml
In which case, you would put the google code after the last in the success.phtml file
add a comment |
I think you would use the file located at or whatever the vendor/template you use
vendor/magento/module-checkout/view/frontend/templates/success.phtml
In which case, you would put the google code after the last in the success.phtml file
add a comment |
I think you would use the file located at or whatever the vendor/template you use
vendor/magento/module-checkout/view/frontend/templates/success.phtml
In which case, you would put the google code after the last in the success.phtml file
I think you would use the file located at or whatever the vendor/template you use
vendor/magento/module-checkout/view/frontend/templates/success.phtml
In which case, you would put the google code after the last in the success.phtml file
edited Apr 12 '17 at 1:21
Rafael Corrêa Gomes
4,54923264
4,54923264
answered Apr 11 '17 at 20:07
dawhoodawhoo
506322
506322
add a comment |
add a comment |
You need to put this code in vendor/magento/module-checkout/view/frontend/templates/success.phtml
.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var $block MagentoCheckoutBlockOnepageSuccess */ ?>
<div class="checkout-success">
<?php if ($block->getOrderId()):?>
<?php if ($block->getCanViewOrder()) :?>
<p><?= __('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?></p>
<?php else :?>
<p><?= __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p>
<?php endif;?>
<p><?= /* @escapeNotVerified */ __('We'll email you an order confirmation with details and tracking info.') ?></p>
<?php endif;?>
<?= $block->getAdditionalInfoHtml() ?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?= /* @escapeNotVerified */ $block->getContinueUrl() ?>"><span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span></a>
</div>
</div>
</div>
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
add a comment |
You need to put this code in vendor/magento/module-checkout/view/frontend/templates/success.phtml
.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var $block MagentoCheckoutBlockOnepageSuccess */ ?>
<div class="checkout-success">
<?php if ($block->getOrderId()):?>
<?php if ($block->getCanViewOrder()) :?>
<p><?= __('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?></p>
<?php else :?>
<p><?= __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p>
<?php endif;?>
<p><?= /* @escapeNotVerified */ __('We'll email you an order confirmation with details and tracking info.') ?></p>
<?php endif;?>
<?= $block->getAdditionalInfoHtml() ?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?= /* @escapeNotVerified */ $block->getContinueUrl() ?>"><span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span></a>
</div>
</div>
</div>
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
add a comment |
You need to put this code in vendor/magento/module-checkout/view/frontend/templates/success.phtml
.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var $block MagentoCheckoutBlockOnepageSuccess */ ?>
<div class="checkout-success">
<?php if ($block->getOrderId()):?>
<?php if ($block->getCanViewOrder()) :?>
<p><?= __('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?></p>
<?php else :?>
<p><?= __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p>
<?php endif;?>
<p><?= /* @escapeNotVerified */ __('We'll email you an order confirmation with details and tracking info.') ?></p>
<?php endif;?>
<?= $block->getAdditionalInfoHtml() ?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?= /* @escapeNotVerified */ $block->getContinueUrl() ?>"><span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span></a>
</div>
</div>
</div>
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
You need to put this code in vendor/magento/module-checkout/view/frontend/templates/success.phtml
.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var $block MagentoCheckoutBlockOnepageSuccess */ ?>
<div class="checkout-success">
<?php if ($block->getOrderId()):?>
<?php if ($block->getCanViewOrder()) :?>
<p><?= __('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?></p>
<?php else :?>
<p><?= __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p>
<?php endif;?>
<p><?= /* @escapeNotVerified */ __('We'll email you an order confirmation with details and tracking info.') ?></p>
<?php endif;?>
<?= $block->getAdditionalInfoHtml() ?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?= /* @escapeNotVerified */ $block->getContinueUrl() ?>"><span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span></a>
</div>
</div>
</div>
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": XXXXXXXXX,
"order_id": "<?php echo $order->getIncrementId() ?>",
"email": "<?php echo $order->getCustomerEmail() ?>",
"delivery_country": "<?php echo $order->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
answered 26 mins ago
Dhaduk MiteshDhaduk Mitesh
662218
662218
add a comment |
add a comment |
app/design/frontend/magento/theme/Magento_Checkout/templates/success.phtml
Add this script
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": xxxxxxxxx,
"order_id": "<?php echo $orderData->getIncrementId() ?>",
"email": "<?php echo $orderData->getCustomerEmail() ?>",
"delivery_country": "<?php echo $orderData->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
This looks like code for Magento 1, not Magento 2.
– Steve Robbins
Nov 14 '17 at 19:27
add a comment |
app/design/frontend/magento/theme/Magento_Checkout/templates/success.phtml
Add this script
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": xxxxxxxxx,
"order_id": "<?php echo $orderData->getIncrementId() ?>",
"email": "<?php echo $orderData->getCustomerEmail() ?>",
"delivery_country": "<?php echo $orderData->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
This looks like code for Magento 1, not Magento 2.
– Steve Robbins
Nov 14 '17 at 19:27
add a comment |
app/design/frontend/magento/theme/Magento_Checkout/templates/success.phtml
Add this script
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": xxxxxxxxx,
"order_id": "<?php echo $orderData->getIncrementId() ?>",
"email": "<?php echo $orderData->getCustomerEmail() ?>",
"delivery_country": "<?php echo $orderData->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
app/design/frontend/magento/theme/Magento_Checkout/templates/success.phtml
Add this script
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": xxxxxxxxx,
"order_id": "<?php echo $orderData->getIncrementId() ?>",
"email": "<?php echo $orderData->getCustomerEmail() ?>",
"delivery_country": "<?php echo $orderData->getShippingAddress()->getCountryId() ?>",
"estimated_delivery_date": "YYYY-MM-DD"
});
});
}
</script>
answered Jun 7 '17 at 12:56
Jyoti ThakurJyoti Thakur
1
1
This looks like code for Magento 1, not Magento 2.
– Steve Robbins
Nov 14 '17 at 19:27
add a comment |
This looks like code for Magento 1, not Magento 2.
– Steve Robbins
Nov 14 '17 at 19:27
This looks like code for Magento 1, not Magento 2.
– Steve Robbins
Nov 14 '17 at 19:27
This looks like code for Magento 1, not Magento 2.
– Steve Robbins
Nov 14 '17 at 19:27
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f167643%2fmagento-2-google-customer-reviews%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown