I would like to manipulate the cart based on tags on products in the cart. I'm currently using the Shopify Ajax API to retrieve the cart contents and then the products in the cart. This leads to performance issues given the number of calls required. This is a classic issue addressed by GraphQL so I'm wondering if there is a solution available
How is making a call to the cart endpoint and getting back the contents a performance issue? Have you thought through what you are trying to do? If you do a single call to the cart, you get all the products in the cart. If you want to manipulate the products in the cart, what does that mean? If you are saying, geez, I need to see the tags of each product, and you then do an ajax call per product to get the tags, you are doing it wrong. Instead, when you place a product in the cart, add the special tag as a line item property. That way, when you want to play with the cart, you have all the data at your fingertips.
This is not a "classic GraphQL" kind of thing in my opinion, but instead, a question of perhaps not adopting the cleanest, fastest pattern of the many you could choose to use.
Related
I am using the Shopify Storefront API for a headless website, I have run into a specific issue where, when I add a variant of a product in the Cart, I can't seem to find a solid way of knowing which variant was added, the current API as is from Storefront doesn't seem to offer an option from the graphQL to know which variant was added.
Thanks in advance!
Technically, I can get this information from the variantBySelectedOptions field, however this only works when adding items to cart, since when I add a product I can send the options of the variant, however this doesn't work when I am simply trying to fetch the current items in my Cart, when for example I'm simply reloading the page, this field always expects some sort of input!
Wondering if I can use the Magento AJAX API (Magento v1.9.2.4) to query products using some basic (or not so basic) filters.
I'm trying to implement a custom 'load-more-on-scroll' feature for a product page. Anytime they scroll down, it should ask the API for new products that have an ID greater than 'previous_id', and possibly targeting a specific category or subcategory.
I've been looking around, but it's not apparent how to do this, and I'm rather new to Magento. Would anyone be able to point me in the right direction, please?
I am creating a website with mailchimp integration using their API. I am using their drag and drop cart block content feature, it seems that the price that is reflected in that block is not the price of the cart but the price of the product.
My first solution is to get the price using a cart merge tag, I have been searching for merge tags but cant find any website that provides me this merge tags.
I would like to use the cart price instead, does anyone knows how can I put the cart price? I've been looking for solution for this problem all day. I hope one of you can help me.
Thank you.
Check this video as well
https://www.youtube.com/watch?v=nTi4nU8ZOj0
You can use the merge tag ABANDONED_CART to create custom html for abandoned cart emails.
Example:
<table>
*|ABANDONED_CART:[$total=3]|*
<tr>
<td><img src="*|PRODUCT:IMAGE_URL|*"/></td>
<td>*|PRODUCT:TITLE|*</td>
<td>*|PRODUCT:PRICE|*</td>
</tr>
*|END:ABANDONED_CART|*
</table>
Go to Cart
The $total=3 in the ABANDONED_CART tag changes the number of products that will be shown.
*|CART:URL|* - Generates the url for your cart.
This doesn't seem possible. Here's a very recent list of available tags from mailchimp . There's no CART block or CART_PRICE tag.
I contacted mailchimp support with a similar query.
ME:
I'd like to customize the contents of the cart
block. The test emails/ abandoned carts I have created use the
checkout_url as the product image link within the template. Is it
possible to have the cart block product image link url set to that of
the product or the product link variant?
If that is not possible is there an equivalent PRODUCT_CART tag to
PRODUCT_RECOMMENDATIONS as documented here
http://kb.mailchimp.com/merge-tags/all-the-merge-tags-cheat-sheet#Merge-Tags-for-Product-Recommendations
that I could use to construct my own abandoned cart email, not using the
predefined cart block drag and drop content block.
In summary:
1) Within the cart block is it possible to have the product images link
to the products and not the checkout_url?
2) Is there a tag not listed in
http://kb.mailchimp.com/merge-tags/all-the-merge-tags-cheat-sheet to
iterate over cart products?
SUPPORT:
There is not a way to change the URL linked to the product image. Additionally, those products must be pulled in using the abandoned cart content blocks, and cannot be populated using a merge tag.
That being said, I do agree these would be great options to have, and I would be happy to pass that feedback along for you. Our developers monitor these suggestions and often use that feedback for future versions of the application. So thank you for giving us your idea, as it may be very useful for a lot of our users in the future.
Let us know if you have any other questions on this, and have a great rest of your day.
Using Shopify Scripts :::
I am trying to achieve the below but getting issue. Could you please let me know how to do this.
$25 off a purchase of $125 or more from the "sale" section. These products have a tag "sale" and are also in a collection "sale" based on that tag.
Looking forward for your quick response.
Great Thanks
If you examine the documentation for Shopify Scripts you'll notice that there is no support for auditing the line item for tags. So you should try the other approach which is proven, and works well.
Look for an item with a compare at price. If you find one, then that typically means the item is on sale. So you can rig your logic to look for items with a compare at price, and if they have one, then determine if the cart has exceeded the $125 in value, and if so, apply your discount.
I can't give you the exact code as I don't know the structure of your code. But this is what you need to do.
Wherever a product can be added to the cart assign a JavaScript function to check if the product is of "Sale" collection. If yes, add an attribute cart.attributes.something.something and keep changing it as and when required.
When the checkout mechanism is present in the page, and if your conditions satisfy the Sale discount, take then to /checkout?DISCOUNT=<CODE> and click of checkout. It'll automatically apply the discount.
I'm very new to Magento.I am having product with some variants like "size" with values "large XX,small XX,medium XX".I want the feature to make any one of this values as default in admin.
my screenshot explanation here
How can i do this
please help me!
When you say you want them to be defaults, you are being a little vague. Are you talking about using configurable products for this? Custom product options? When you say "default in admin", what do you mean? Which page are you referring to? More detail will help us answer the question.
Thanks,
Joe
As far as I know, what you are asking for is not a default functionality of Magento, but it shouldn't be difficult to add some javascript to allow you to force selections at page load time. Ultimately, it's just code, so it's definitely possible to do.
my suggestion would be to add a attribute to all you products called for instance "defaultselect" then you can enter your value easily from the backend to your configurable product.
so now you have a configurable product say a hat which comes in 3 sizes, and has 3 assigned simple products. set the defaultselect value to one of the size values
now some layout xml and javascript is required to get you product attribute to work with the magento selects.
first you want to actually include you js. this is done through the layout xml. you can include update using add js method for PRODUCT_TYPE_configurable handle
now the js. store the js in the skin js folder.
to make this work you would need to know the configurable product defaultselect attribute value we're testing against. this could be retrieved with your own ajax function to a method which checks if the current product has a defaultselect attribute and returns it's value or false.
if you have a value from your ajax function you can work with that ie you have both the returned attributes from the configurable product and magento will return the rest.
however after that it seems to get complicated your going to have to do something with the js magento aready uses to render product options