Redirect user to a page after payment in shopify - asp.net

I am using shopify,
I send user to shopify with certain product number and quantity, which is being populated with price on shopify where user can make a payment,
Now i want the user to be redirected to a certian page in my website, after successful payment,
I created webhook order payemnt and given the url of the page to be redirected after payment, but it is not working
Please suggest
Thanks

You could set up a redirect by visiting Settings > Checkout and pasting this into the text box for Additional content & scripts.
<style type="text/css">body {display:none}</style>
<script type="text/javascript">
window.location.replace("http://yahoo.com");
</script>

If you are looking to redirect a customer to a different URL depending on the product they purchased, then here is some code I created to do that.
NOTE: This code is inserted into the Additional Scripts section of the Checkout area. To go there go to Settings > Checkout > scroll down to Additional Scripts.
This solutions uses the Shopify checkout object selector #Altin provided.
Keep in mind, this solution works uniquely for my Shopify experience because customers can only buy 1 product at a time. If your customers can add multiple items to their carts, than a for loop should be used, likely around the for in loop.
<script>
const idUrlList = {
// Replace the content below here with your own
"product1": {
"url": "https://www.URL-HERE.com",
"product_id": 1234567898765,
},
"product2": {
"url": "https://www.URL-HERE.com",
"product_id": 1234567898765,
},
"product3": {
"url": "https://www.URL-HERE.com",
"product_id": 1234567898765,
},
"product4": {
"url": "https://www.URL-HERE.com",
"product_id": 1234567898765,
},
// Replace the content above here with your own
};
// Do NOT change anything below this line
const productPurchasedId = Shopify.checkout.line_items[0].product_id;
for (const product in idUrlList) {
if (idUrlList[product].product_id === productPurchasedId) {
window.location.replace(`${idUrlList[product].url}`);
}
else {
console.log(`Found no matches in dictionary.
The dictionary ID is ${idUrlList[product].product_id}
The product ID is ${productPurchasedId}`);
};
};
</script>
To make this work for you, make the following replacements:
Replace "product1" with the name of the product or redirect that you will find memorable. For example, in one of mine I wrote "20_off_2020".
Replace https://www.URL-HERE.com with the link you want people to go to. For example, https://theamsalems.com/
Replace 1234567898765 with the unique product ID that you want to check for. This can be found in Shopify. Go to Products, click on a product, and grabbing the string of numbers at the end of the URL.
Add/remove the other products depending on how many products you have. For example, if you only have two products, remove the code from "product3" all the way up to the line which says // Replace the content above here with your own.
The rest of this code will automatically handle finding product IDs and handling their correct redirects.
Here are some of my references to building this solution:
Shopify checkout object, line_items array
Line items product ID
I also found out you can test your pages using a Bogus Gateway. Shopify documentation available here.

Related

Installment widget - Wordpress + Woocommerce

What's the problem?
I want to add a PayU plugin installment widget for a product subpage for WooCommerce, but I have a problem with displaying the product price in the calculator provided in the documentation.
Code source for implementing such a calculator:
https://developers.payu.com/en/installments.html#installments_best_practices_mini
<p><span id="installment-mini"></span></p>
<script type="text/javascript">
var value = 1234.56;
if (value >= 300 && value <= 50000) {
var options = {
creditAmount: value,    // amount in PLN
posId: '67328',         // point of sale identifier
key: 'zQ',              // first two characters of API key
showLongDescription: true
};
  OpenPayU.Installments.miniInstallment('#installment-mini', options)
.then(function(result) {
// This fragment of code will be executed after widget is shown
// parameter ‘result’ contains additional functions
})
.catch(function(e) {
console.error(e.toString()); // This snippet writes config errors
// to developer’s console
});
}
What do i want to get?
I want only the product price in the product card to be downloaded to the installment calculator. There is no input field in the product card, only , I thought about a positive in the php code but it did not work. I want to add a regular price or the price of a product variant to the JS code to show the customer what he can do when choosing installments, so the price must be taken to the code above.

How do you add an item to an existing cart using BigCommerce's Storefront Cart API?

I'm having difficulty using the BigCommerce Storefront Cart API as described in their docs
When I manually send an http request through the fetch api using a console window open on the storefront website, it always comes back with 404 "Cart does not exist".
This is the fetch request I'm using:
fetch(
'/api/storefront/carts/e475da57-e9d1-4da0-b9bf-ac4c34b8d601/items',
{
credentials: 'same-origin',
method: 'POST',
body: JSON.stringify({ lineItems: [{ quantity: 1, productId: 2968 }]})
}
).then(res => res.json()).then(console.log)
I got the id by going to <store-url>/api/storefront/cart
When I simply do a GET on the same cart id, it sends back an object as expected.
I have no trouble when I make a new cart. It's only a problem if I want to add items to an existing cart.
I've tried adding a trailing forward slash, singular and plural forms of carts and items and lineItems

Wix: Events Tracking in Google Analytics

I went through the tutorial to set this up (at https://support.wix.com/en/article/wix-code-tutorial-sending-tracking-and-analytics-events) but I can't see the events in Google Analytics. My configuration is the following:
I have a button on one of my pages with the id of downloadButtonNewbornBrochure which as its name says is linked to a file download. I placed the following code on the page:
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixWindow from 'wix-window';
export function downloadButtonNewbornBrochure_click(event) {
wixWindow.trackEvent("CustomEvent", {
"event": "Download",
"eventCategory": "Newborn",
"eventAction": "Brochure Download"
} );
}
$w.onReady(function () {
//TODO: write your page related code here...
});
In Google Analytics I have a Goal specified and enabled:
Custom goal
Goal name: Download
Type: Event
Category Equal To Newborn
Action Equal To Brochure Download
Label empty
Value empty
Use the Event value as the Goal Value for the conversion: yes
When I verify or test this button, no events are captured. Where have I gone wrong?

Google Product Reviews with Wordpress + WooCommerce

Does anyone know how to integrate the new Google Product Reviews with WooCommerce?
Google provide instructions that are below but not sure how this would worth with Woo.
If anyone can point me in the right direction, it would be very much appreciated!!
Add the opt-in code
To give your customers the option of submitting a review of their experience buying from you, add the opt-in module to your order confirmation page.
To add the survey opt-in module to your order confirmation page:
Paste the following HTML snippet into your order confirmation page:
<!-- BEGIN GCR Opt-in Module Code -->
<script src="https://apis.google.com/js/platform.js?onload=renderOptIn"
async defer>
</script>
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
// REQUIRED
"merchant_id": MERCHANT_ID,
"order_id": "ORDER_ID",
"email": "CUSTOMER_EMAIL",
"delivery_country": "COUNTRY_CODE",
"estimated_delivery_date": "YYYY-MM-DD",
// OPTIONAL
"opt_in_style": "OPT_IN_STYLE"
});
});
}
</script>
<!-- END GCR Opt-in Module Code -->
Place the code just before the closing </BODY> tag. When you place the survey module code with the badge code, the order does not matter: the survey module code can be before or after the badge code.

Share activity on Google Plus using asp dotnet

How can i post an interactive post on google+ stream?
I am trying to post some custom data on google stream from asp.net web application.
This is the code iam using.
this is .aspx page:
Tell your friends
this is the script i am using:
var moment = {
"name": "sample",
"Description": "Hi sample post",
"Thumbnail": "logo",
"image": "http://prayati.com/Images/PrayatiLogo.jpg"
};
gapi.auth.init(signinCallback);
function signinCallback(authResult) {
if (authResult['access_token']) {
gapi.interactivepost.render('inter', options);
//gapi.interactivepost.render(moment, authResult['access_token'])
gapi.interactivepost.go(moment)
document.getElementById('myBtn').setAttribute('style', 'display: none');
} else if (authResult['error']) {
alert(authResult['error']);
}
}
var options = {
contenturl: 'https://plus.google.com/pages/',
contentdeeplinkid: '/pages',
clientid: '263087742134.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
prefilltext: 'Create your Google+ Page too!',
calltoactionlabel: 'SHARE',
calltoactionurl: 'http://plus.google.com/pages/create',
calltoactiondeeplinkid: '/pages/create'
};
The first and probably most important problem is that you have a domain mismatch between your data-calltoactionurl and your data-contenturl. These must be the same domain, see the data-contenturl documentation.
I believe that is your major problem, there are other problems in your example too:
You appear to be confusing two different features: app activities (aka moments) and interactive posts. Also, it looks like you are trying to do authentication, the interactive post button is also a sign-in button, notice its data-callback parameter. You wouldn't need to do a separate call to gapi.auth.init()
The most simple approach is to use the HTML button and remove the calls to gapi.interactivepost.* unless you have a dynamic application that needs to insert buttons with great control.
You didn't post the code for your JavaScript API include, ensure that it is loading the API script as https://apis.google.com/js/client:plusone.js.
Here is a correct and simplified button:
<button class="g-interactivepost"
data-clientid="xxxxxxxxxx.apps.googleusercontent.com"
data-contenturl="http://localhost:52022/Jaswanth"
data-cookiepolicy="single_host_origin"
data-calltoactionlabel="INVITE"
data-calltoactionurl="http://localhost:52022/create"
data-prefilltext="Best site EVER!"
data-callback="signinCallback"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login">
Tell your friends
</button>

Resources