Skip to content

Instantly share code, notes, and snippets.

View AlexWebLab's full-sized avatar

Alex AlexWebLab

View GitHub Profile
{% unless grid_item_width %}
{% assign grid_item_width = 'large--one-third medium--one-half' %}
{% endunless %}
{% include 'buyx-price-min' with product %}
{% assign on_sale = false %}
{% if product.compare_at_price > buyx_price_min %}
{% assign on_sale = true %}
<!-- /templates/product.liquid -->
{% include 'buyx-product' with product %}
{% include 'buyx-price-min' with product %}
<div itemscope itemtype="http://schema.org/Product">
<meta itemprop="url" content="{{ shop.url }}{{ product.url }}">
<meta itemprop="image" content="{{ product.featured_image.src | img_url: 'grande' }}">
after
{{item.variant.title}}
add
<span class="saso-cart-item-discount-notes" data-key="{{item.key}}"></span>
<span class="saso-cart-item-upsell-notes" data-key="{{item.key}}"></span>
==
@AlexWebLab
AlexWebLab / string-utils.js
Created September 11, 2018 08:30 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();
@AlexWebLab
AlexWebLab / geoip.js
Created August 20, 2018 03:04 — forked from panoply/geoip.js
GeoIP Redirect using javascript
<script>
function geo(a) {
switch (a.country.code)
{
case "SE": // Redirect is visitor from Sweden
case "NO": // Redirect is visitor from Norway
case "DK": // Redirect is visitor from Denmark
window.location = "https://se.brixtol.com" + window.location.pathname; // edit for your URL
break;
default:
@AlexWebLab
AlexWebLab / index.php
Created March 13, 2018 10:05
Get page ID by template name in WordPress
<?php
$args = [
'post_type' => 'page',
'fields' => 'ids',
'nopaging' => true,
'meta_key' => '_wp_page_template',
'meta_value' => 'page-special.php'
];
$pages = get_posts( $args );
foreach ( $pages as $page )
@AlexWebLab
AlexWebLab / style.css
Last active September 12, 2023 17:05
Retina displays CSS background image
.logo_background {
background-image: url('../img/logo@1x.png');
background-position: center center;
background-repeat: no-repeat;
background-size: 80px 40px; /* size of the logo image @ 1x */
}
@media /* only for retina displays */
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min--moz-device-pixel-ratio: 2),
only screen and (min-device-pixel-ratio: 2),
@AlexWebLab
AlexWebLab / functions.php
Last active April 24, 2017 06:19
Resizing and showing images from ACF in WordPress theme development for page load performance optimisation
<?php
add_action( 'after_setup_theme', 'custom_image_sizes' );
function custom_image_sizes() {
add_image_size( 'image-1400px-wide', 1400 ); // 1400 pixels wide (and unlimited height)
add_image_size( 'image-700px-wide', 700 ); // 700 pixels wide (and unlimited height)
add_image_size( 'image-350px-wide', 350 ); // 350 pixels wide (and unlimited height)
}
@AlexWebLab
AlexWebLab / functions.php
Last active April 24, 2017 05:55
Extend WordPress search to include advanced custom fields
<?php
/**
* Extend WordPress search to include custom fields
*/
/**
* Join posts and postmeta tables
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
*/
@AlexWebLab
AlexWebLab / file.php
Last active March 22, 2019 05:23
Create Bootstrap tabs from Advanced Custom Fields
<div id="with_tabs_container" class="flex no-flex-xs-block">
<div class="left_column">
<?php if ( have_rows('tabs') ) { ?>
<ul class="list-unstyled green_tablist" role="tablist">
<?php $i=1; while ( have_rows('tabs') ) { the_row(); ?>
<li role="presentation" class="<?php if(1==$i) echo 'active'; ?>">
<a href="#tab_pane_<?php echo $i; ?>" role="tab" data-toggle="tab" title="<?php echo esc_attr(get_sub_field('tab_name')); ?>"><?php the_sub_field('tab_name'); ?></a>
</li>