Git Product home page Git Product logo

shopify-code-snippets's People

Contributors

freakdesign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shopify-code-snippets's Issues

Search by SKU Snippet

To note, the example doesn't work:

https://jasons-experiments.myshopify.com/search?type=product&q=sku:23200&view=sku

This does though:

https://jasons-experiments.myshopify.com/search?type=product&q=23200&view=sku

Caching issue?

Hi Jason, the snippet has been working all year long! But today, something has been weird.

I have several pages, let's imagine them like this:
https://www.mystore.com/pages/repair?p=item1&cache=false
https://www.mystore.com/pages/repair?p=item2&cache=false
https://www.mystore.com/pages/repair?p=item3&cache=false

If I visit the repair page with item1, the pageurl will be correct and everything will work properly.
Now my hope is that when I visit item2, the pageurl will also reflect p=item2, but it doesn't. It remains with item1. The same result as if I visited item3, the pageurl will contain item1.

Note the real URL will say https://www.mystore.com/pages/repair?p=item2&cache=false
or https://www.mystore.com/pages/repair?p=item3&cache=false. But the content_for_header pageurl: will reflect the first visited https://www.mystore.com/pages/repair?p=item1&cache=false. It looks like content_for_header isn't updating the pageurl?

Would love to get some help on this, as I haven't modified any code since it's always been working.
Thanks for the good work :)

update date_translate snippet to use localiszation object for automatic translation

{%- comment -%}
    {%- render 'date_translator', date: date, format: format -%}
{%- endcomment -%}
{% liquid 
    assign datesSupported = 'en,no,fr,es,de' | split:','
    assign dateFormat = format | default: '%A %B %d, %Y'
    assign dateString = date | date: dateFormat
    if datesSupported contains localization.language.iso_code and dateString != blank
        assign daysen = 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday' | split:','
        assign monthsen = 'January,February,March,April,May,June,July,August,September,October,November,December' | split:','
        assign daysno = 'Mandag,Tirsdag,Onsdag,Torsdag,Fredag,Lørdag,Søndag' | split:','
        assign monthsno = 'Januar,Februar,Mars,April,Mai,Juni,Juli,August,September,Oktober,November,Desember' | split:','
        assign daysfr = 'Lundi,Mardi,Mercredi,Jeudi,Vendredi,Samedi,Dimanche' | split:','
        assign monthsfr = 'Janvier,Février,Mars,Avril,Mai,juin,Juillet,Août,Septembre,Octobre,Novembre,Décembre' | split:','
        assign dayses = 'Lunes,Martes,Miércoles,Jueves,Viernes,Sábado,Domingo' | split:','
        assign monthses = 'Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre' | split:','
        assign daysde = 'Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag' | split:','
        assign monthsde = 'Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember' | split:','
        assign currentDays = 'days' | append: localization.language.iso_code
        assign currentMonths = 'months' | append: localization.language.iso_code
        assign currentDaysArray = [currentDays]
        assign currentMonthsArray = [currentMonths]
        assign shortSlice = 3
        for i in (0..11)
            if i < 7
                assign shortDateFormatEnglish = daysen[i] | slice:0,shortSlice
                assign shortDateFormatCurrent = currentDaysArray[i] | slice:0,shortSlice
                assign dateString = dateString | replace:daysen[i],currentDaysArray[i] | replace:shortDateFormatEnglish, shortDateFormatCurrent
            endif
            assign shortMonthFormatEnglish = monthsen[i] | slice:0,shortSlice
            assign shortMonthFormatCurrent = currentMonthsArray[i] | slice:0,shortSlice
            assign dateString = dateString | replace:monthsen[i],currentMonthsArray[i] | replace:shortMonthFormatEnglish, shortMonthFormatCurrent
        endfor
        echo dateString
    endif
%}

Add other variables to outputted JSON, returning null?

I need access to check if the product only has a default variant. I noticed it wasn't included in your example, but no problem, I figured I would just add it in within the items loop but for some reason, it always returns null.

I did a test and output the cartJson variable you create based on the native cart object and within that, all of the values are correct for that product_only_has_default_variant variable, but when I try to manually create that variable while building the template JSON, it returns null. What am I missing here?

This is what I added to the items loop...

"product_has_only_default_variant": {{ item.product_has_only_default_variant | json }},

Can’t get Shopify cart via jsonp crossdomain anymore

I’m using “Get Shopify cart data with JSONP“. Since a couple of days ago the request returns empty carts. Anyone else experiencing the same?

I make sure the Shopify store has items in the cart, but when getting the cart via Jsonp from another domain the cart response is without any cart items. Did Shopify change it’s api in some way?

starts-with example doesn't give expected result

Using the starts-with example, I tried to detect if the current page URL matches a certain page:

{% assign stringToCheck = page.url %}
{% assign startsWith = '/about/' %}
{% assign checkArray = stringToCheck | split:startsWith %}

{% if checkArray[0] == blank %}
  The string {{ stringToCheck }} does start with {{ startsWith }}.
{% else %}
  The string {{ stringToCheck }} does NOT start with {{ startsWith }}.
{% endif %}

However, with that snippet, I get this on the page:

The string /about/ does NOT start with /about/.

Though, this works for me:

{% assign stringToCheck = page.url %}
{% assign startsWith = '/about/' %}
{% assign checkArray = stringToCheck | split:startsWith %}

{% assign checkSlice = stringToCheck | slice: 0, stringToCheck.size %}
{% if checkSlice == startsWith %}
  The string {{ stringToCheck }} does start with {{ startsWith }}.
{% else %}
  The string {{ stringToCheck }} does NOT start with {{ startsWith }}.
{% endif %}

Which, as I implied, outputs:

The string /about/ does start with /about/.

Which Folder

Hi, you have gone so far with this and that is awesome. It would be helpful if you gave users a full solution by simply showing which folder they should be creating this file in

Shopify persitent cart without apps is not working

Hi, I am having hard time using this snippet on my shopify store. I copied the code and added hmac but it's not working. It's not even sending the request. See Here
Create a test account it's fine, I console logged customer ID and cookie but to no avail. Thanks, hope we can fix this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.