Skip to content

Instantly share code, notes, and snippets.

Michaël Gallego bakura10

Block or report user

Report or block bakura10

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View test.php
$variants = [];
foreach ($shopifyClient->getVariantsIterator(['fields' => 'id,inventory_quantity']) as $variant) {
$variants[$variant['id']] = $variant['inventory_quantity'];
}
foreach ($products as $index => $product) {
$delay = (int) ($index / 4);
if ($product['quantity'] === $variants[$product['id']] {
View test.php
foreach ($products as $index => $product) {
$this->messageQueue->push(new DelayedMessage('product.validate_stock', [
'product' => $product['id']
], $index);
}
$this->messageQueue->flush();
@bakura10
bakura10 / instagram-patch.liquid
Created Jan 12, 2018
Update to fix the Instagram Section for Kagami—premium Shopify theme
View instagram-patch.liquid
<script>
window.addEventListener("DOMContentLoaded",function(){var e=function(e,t){new Instafeed({get:"user",userId:"self",accessToken:e,sortBy:"most-recent",limit:t,resolution:"standard_resolution",template:{% raw %}'<div class="instagram__image-wrapper instagram-fix"><a href="{{link}}" style="background-image: url({{image}})" target="_blank"><div class="instagram__overlay"><p class="instagram__caption">{{caption}}</p><time class="instagram__date">{{model.created_time}}</time></div></a></div>'{% endraw %},after:function(){$("#instafeed-mobile").append($("#instafeed").html())},filter:$.proxy(function(e){var t=new Date(1e3*e.created_time);m=t.getMonth(),d=t.getDate(),y=t.getFullYear();var a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return e.created_time=a[m]+" "+d+", "+y,!0})}).run()};!function(t){var a=t.attr("data-instagram-access-token"),n=t.attr("data-twitter-username");a&&e(a,n?3:6)}($(".index-module__social"))});
</script>
<style>
.instagram__image-wrapper > a {
p
@bakura10
bakura10 / instagram-patch.liquid
Created Jan 12, 2018
Update to fix the Instagram Section for Focal—premium Shopify theme
View instagram-patch.liquid
<script>
window.addEventListener("DOMContentLoaded",function(){var a=function(a){var e=new Date(1e3*a.created_time),t=e.getMonth(),n=e.getDate(),i=e.getFullYear(),r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return a.created_time=r[t]+" "+n+", "+i,!0},e=function(e){var t={% raw %}'<div class="instagram-fix grid__cell 1/2 1/3--handheld-and-up 1/'+e.attr("data-images-per-row")+'--lap-and-up"><div class="instagram__image-wrapper" style="background-image: url({{image}})"><a href="{{link}}" target="_blank"><div class="instagram__overlay"><p class="instagram__caption">{{caption}}</p><time class="instagram__date">{{model.created_time}}</time></div></a></div></div>'{% endraw %};new Instafeed({get:"user",userId:"self",accessToken:e.attr("data-access-token"),sortBy:"most-recent",limit:e.attr("data-limit-images"),resolution:"standard_resolution",template:t,filter:$.proxy(a)}).run()};$(".index-module__instagram[data-access-token]").each(function(a,t){e($(t))})});
</script>
<style>
.ins
View gist:c43062615c175c5e79075a24d368c8e6

DISCLAIMER: this is not really only about slate, just rough ideas on what I'd like to see in Shopify and that could be achieved in JS.

Hi everyone,

I had a talk with @t-kelly a few days ago and I'd like to expand on an idea that should represent what Slate could be in the future or what are the main frustration points in developing Shopify Themes.

Origin

We're now trying to develop more and more complex themes, both for the theme stores and clients. We're always trying to push the boundaries of what is possible with Shopify.

View gist:afa21c88d05c25c36d67ffb85630b836
Pipeline events:
* add_product.pre
* add_product.post
Theme could add messages to the pipeline:
ShopifyApi.Pipeline.addProduct(1234, 1).then(function(pipelineStatus, cart) {
// do things
});
View command.php
<?php
class SendSmsHandler
{
public function __invoke(SendSms $command)
{
if ($this->usageService->exceedsQuota($command->getShopDomain())) {
// Update
}
}
View gist:9b1cfbba1f845032e050
Another idea I had was to create a pre_routing middleware, that would change the URL, so that next step Expressive would
"dispatch" to the next middleware
View test.php
<?php
class MyMiddleware
{
private $mapping;
public function __invoke($request, $response, $out)
{
$var = $request->getAttribute('job');
$middleware = $this->mapping[$var];
View gist:fedc9c743f3757aeafe5
<!-- Let's say we have a "block" that displays a product's title and price: -->
<div class="product-meta">
<h2 class="product-meta__title">Foo</h2>
<p class="product-meta__price">Price</h2>
</div>
<!-- This block has specific styling on a given page. There are other pages when this block is actually included
inside another block. Most styles will be the same, but with very little variations.-->
You can’t perform that action at this time.