"Need Help with Custom Shopify Scripts - Free Products for Logged-In Users"

Yaska

New member
Joined
Aug 19, 2011
Messages
3
Reaction score
0
"Hey guys, I'm trying to create a custom Shopify script that'll give logged-in customers free products with every purchase. I've got the logic down, but I need help with the implementation - anyone have experience with Shopify's JavaScript API and Liquid templating? I'm new to this so any guidance would be super appreciated!"
 

almus

Member
Joined
Sep 7, 2007
Messages
7
Reaction score
0
"Hey OP, I've worked with Shopify scripts before and I think I can help you out. Can you share more about your setup and what you're trying to achieve? Do you have a specific coding language in mind (e.g Twig, Liquid)?"
 

MANYMENT

New member
Joined
Mar 4, 2005
Messages
4
Reaction score
0
"Hey OP, I think I can help you out. We've got a similar script on our store that rewards logged-in customers with free products after reaching a certain order total. PM me and I'll send over the code snippets, we can work out the details from there."
 

onion99

Member
Joined
Oct 1, 2017
Messages
6
Reaction score
0
"Hey OP, I've worked with Shopify scripts before. Can you give more details on what you're trying to accomplish? Like, what's the condition for a free product and how's the script gonna know a user's logged in?"
 

sascha

New member
Joined
May 20, 2006
Messages
4
Reaction score
0
"Hey OP, I've dealt with similar issues before. You'll need to create a customer segment with conditions for logged-in users and then use a code like `customer.tags == 'logged_in'` to determine whether to apply the discount or free product logic. Can you share more about your script setup?"
 

Mishanoid

Member
Joined
Mar 14, 2011
Messages
9
Reaction score
2
"Hey OP, I took a quick glance at the Shopify API and it seems like you can use the customer.session object to check if a user is logged in. Once you've got that, you can use the product.update line of code to set a product as free for that specific customer. Give that a shot and see what happens!"
 

lorien01

Member
Joined
Aug 23, 2005
Messages
9
Reaction score
0
"Hey, I think I'd be able to help you out with custom Shopify scripts. I've done a few projects like this in the past, and it sounds like you're looking to give logged-in users discounts or free products. Can you provide more context on what you're trying to achieve and what you've tried so far?"
 

Dimitrij70

Member
Joined
Jan 22, 2010
Messages
5
Reaction score
0
"Hey OP, did you check out Shopify's API documentation for logged-in user scripts? You can use something like this: `customer = current_customer; then if customer != nil, provide the free product`, but you'd need to modify it to fit your needs. Let me know if you need more help!"
 

WORON

Member
Joined
May 9, 2007
Messages
5
Reaction score
0
"Yo, I might be able to help you out here. I've worked with Shopify scripts before and I think I can point you in the right direction. Can you share some more info about what you've tried so far or what you're trying to achieve with the free product script?"
 

przy100jniak

Member
Joined
Apr 3, 2006
Messages
6
Reaction score
0
"Hey OP, I'm interested in helping with that script. If you're giving away free products to logged-in users, you might want to consider adding some security measures to prevent abuse. Can you share some more details about the script you want to create?"
 

Typepreolve

Member
Joined
Oct 5, 2008
Messages
5
Reaction score
0
"Hey OP, I'd suggest checking out the Shopify API and seeing if you can use the 'customer' object to verify whether a user is logged in. You can then use an if statement to apply the free product policy based on that. I've done something similar with membership plans, might be worth looking into."
 
Top