Skip to content

Instantly share code, notes, and snippets.

@Maybach91
Maybach91 / collection-load-more.js
Last active October 27, 2023 13:19
[Shopify Load More Products Button Javascript] its the vanilla javascript version #shopify #loadmore #products #collection #tailwind
const products_on_page = document.getElementById('product-grid');
let next_url = products_on_page.dataset.nextUrl;
const load_more_btn = document.getElementsByClassName('load-more_btn')[0];
const load_more_spinner = document.getElementsByClassName('load-more_spinner')[0];
async function getNextPage() {
try {
let res = await fetch(next_url);
return await res.text();
} catch (error) {
@hpawe01
hpawe01 / infinite-scroll.js
Last active March 10, 2023 06:07
Shopify Dawn Infinite Scroll for Collections (modern plain javascript)
class InfiniteScroll extends HTMLElement {
constructor() {
super();
this.productsContainerSelector = this.getAttribute('data-products-container');
this.paginationSelector = this.getAttribute('data-pagination-selector');
this.nextPageSelector = this.getAttribute('data-next-page-selector');
this.productsContainerEl = this.querySelector(this.productsContainerSelector);
this.paginationEl = this.querySelector(this.paginationSelector);
this.loadingIndicator = this.querySelector('.loading-overlay-wrapper');
@atikju
atikju / related-articles.liquid
Created February 25, 2021 11:24
Show related articles based on article tags - Shopify
@tao-s
tao-s / sample.json
Created December 13, 2020 23:57
ShippingDetails sample
"shippingDetails": [
{
"@type": "OfferShippingDetails",
"shippingRate": {
"@type": "MonetaryAmount",
"value": "610",
"currency": "JPY"
},
"shippingDestination": {
"@type": "DefinedRegion",
<?php
add_action( 'wp_enqueue_scripts', function () {
wp_register_script( 'my-script', get_stylesheet_directory_uri() . '/assets/js/my-script.js' );
wp_enqueue_script( 'my-script' );
} );
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
@webinmd
webinmd / modx.set.php
Created May 22, 2019 17:42
Создает настройки, чанки и поля после установки modx
<?php
require_once dirname(__FILE__).'/config.core.php';
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
header("Content-type: text/plain");
@lukecav
lukecav / functions.php
Created October 15, 2018 23:08
Add multiple products to cart from URL link in WooCommerce
function woocommerce_maybe_add_multiple_products_to_cart() {
// Make sure WC is installed, and add-to-cart qauery arg exists, and contains at least one comma.
if ( ! class_exists( 'WC_Form_Handler' ) || empty( $_REQUEST['add-to-cart'] ) || false === strpos( $_REQUEST['add-to-cart'], ',' ) ) {
return;
}
// Remove WooCommerce's hook, as it's useless (doesn't handle multiple products).
remove_action( 'wp_loaded', array( 'WC_Form_Handler', 'add_to_cart_action' ), 20 );
$product_ids = explode( ',', $_REQUEST['add-to-cart'] );
@ibndawood
ibndawood / functions.php
Created December 14, 2016 14:24
Electro - Make footer widget full width
add_filter( 'electro_register_footer_widgets_args', 'ec_child_modify_footer_widgets_args' );
function ec_child_modify_footer_widgets_args( $args ) {
$args[ 'before_widget' ] = '<div class="col-xs-12"><aside id="%1$s" class="widget clearfix %2$s"><div class="body">';
return $args;
}
@stevenkellow
stevenkellow / woocommerce-order-referrer.php
Created June 23, 2016 08:42
Add Referrer to WooCommerce order
<?php
// Set cookie for new users
add_action( 'init', 'set_newuser_cookie'); // Run when WordPress loads
function set_newuser_cookie() {
$cookie_value = $_SERVER["HTTP_REFERER"]; // Get URL the user came to your site for
if ( !is_admin() && !isset($_COOKIE['origin'])) { // If not an admin or if cookie doesn't exist already
setcookie( 'origin', $cookie_value, time()+3600*24*30, COOKIEPATH, COOKIE_DOMAIN, false); // Set cookie for 30 days
}
@Jekins
Jekins / Markdown-docs.md
Last active June 2, 2024 19:18
Руководство по оформлению Markdown файлов

Руководство по оформлению Markdown файлов

Markdown - это облегчённый язык разметки, который преобразует текст в структурированный HTML. Следующее руководство поможет вам разобраться, как использовать Markdown.

Заголовки

# Заголовок первого уровня
## Заголовок второго уровня
### Заголовок третьего уровня
#### Заголовок четвёртого уровня
##### Заголовок пятого уровня