Skip to content

Instantly share code, notes, and snippets.

@xlawok
xlawok / slide.js
Created September 16, 2021 06:50
slide table jQuery
var table_cnt = $('.product_sec_insurance_comparision');
if($(table_cnt)){
var times_to_left=0;
var my_window=$( window ).width();
var my_table=$('#product-overview-1');
var cnt= $('#product-overview-cnt-1').width();
var move_me_left;
count_columns=$('#product-overview-1 th').length;
table_size=cnt;
col_size=table_size / count_columns;
@xlawok
xlawok / gist:8927e66eebd5f86251d25af166cf6401
Created September 16, 2021 06:49
3 slides with one centered and arrow rotation
$('body').on('click', '.prev-next.go-slide2', function(e) {
if($('.realizacja-first-gallery-image').hasClass('go-left')){
$('.realizacja-first-gallery-image').addClass('go-right');
$('.realizacja-first-gallery-image').removeClass('go-left');
$('.realizacja-first-gallery-image').css('transform','translateX(30vw)');
$('.prev-next.go-slide2').css('transform','rotate(180deg)');
}
else{
$('.realizacja-first-gallery-image').addClass('go-left');
@xlawok
xlawok / slider.js
Created September 16, 2021 06:45
jQuery plain slider - img only sliding - header is still
var arrow_wrapper=$('.arrow-wrapper');
if($(arrow_wrapper)){
var prev=$('.arrow-wrapper .prev');
var next=$('.arrow-wrapper .next');
var banner_imgs = $('.banner-img-wrapper .banner-img-cnt');
var banner_img_length = $(banner_imgs).length;
console.log(banner_img_length);
$(next).click(function(e) {
e.preventDefault();
let active_img=$('.banner-img-wrapper .banner-img-cnt.active').index();
@xlawok
xlawok / head.tpl
Last active July 20, 2021 12:18
Prestashop title and canonical
{assign var="aw_url" value=$smarty.server.REQUEST_URI}
{if strpos($aw_url,'?') !== false}
<meta name="robots" content="noindex, follow">
{elseif $page.meta.robots !== 'index'}
<meta name="robots" content="{$page.meta.robots}">
{/if}
{if $page.page_name=="category"}
@xlawok
xlawok / ProductListingFrontController.php
Created July 18, 2021 21:37
Prestashop 1.7 custom pagination for certain categories
<?php
/**
* 2007-2019 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
@xlawok
xlawok / header.php
Created May 10, 2021 18:44
Woocommerce paged category and tags canonical
<?php
if(is_paged()&&is_product_category()) {
$thisCat = get_query_var('product_cat');
$category_link = get_term_link($thisCat, 'product_cat');
echo '<link rel="canonical" href="' . $category_link . '" />';
}
if(is_paged()&&is_product_tag()) {
$thisTag = get_query_var('product_tag');
@xlawok
xlawok / carbonfields.php
Created January 8, 2021 14:23
Wordpress - Carbon fields + contact form 7 list all forms
<?php
// define( 'Carbon_Fields\URL', get_parent_theme_file_path( 'vendor/htmlburger/carbon-fields' ) );
// \Carbon_Fields\Carbon_Fields::boot();
define('Carbon_Fields\URL', WP_PLUGIN_URL. '/carbon-fields/vendor/htmlburger/carbon-fields');
use Carbon_Fields\Container;
use Carbon_Fields\Field;
function sc_get_contact_forms7(){
@xlawok
xlawok / functions.php
Created December 19, 2020 21:48
Carbon fields undefined core.min.js not visible carbon fields in admin area.
<?php
// probably there is a problem with directory to carbonfield plugin.
// As it is shown under this url https://github.com/htmlburger/carbon-fields/issues/457
// this problem appears when plugin is in symlinked directory.
// add below line to function.php
define('Carbon_Fields\URL', WP_PLUGIN_URL. '/carbon-fields/vendor/htmlburger/carbon-fields');
@xlawok
xlawok / functions.php
Last active December 19, 2020 21:49
Woo + carbonfields - shipment modyfication - weight, zones and country, and class
//carbonfields settings:
function pk_get_shipping_countries(){
//get shipping countries for defining countries for bulky products
$woo_countries = new WC_Countries();
$countries = $woo_countries->get_allowed_countries();
return $countries;
}
function pk_get_shipping_zones(){
@xlawok
xlawok / Woo + carbonfields - shipment modyfication - weight and country
Created December 7, 2020 14:21
Woo shipment modyfication - based on weight and country, with on Carbon Fields on board
add_filter( 'woocommerce_package_rates', 'pk_woocommerce_shipping_by_weight', 9999, 2 );
function pk_woocommerce_shipping_by_weight( $rates, $package ) {
$destination = $package['destination'];
$country = $destination['country'];
//cost sets in carbonfields for each reagions
$pl_shipping_costs = carbon_get_theme_option( 'pk_shipping_costs_pl' );
$inter_shipping_costs = carbon_get_theme_option( 'pk_shipping_costs_inter' );
$cart_weight=WC()->cart->get_cart_contents_weight();