$('.responsive').slick({
dots: false,
arrows: true,
nextArrow: '<i class="fa fa-angle-right" aria-hidden="true"></i>',
prevArrow: '<i class="fa fa-angle-left" aria-hidden="true"></i>',
infinite: false,
speed: 300,
slidesToShow: 3,
slidesToScroll: 3,
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: false,
arrows: true,
dots: false
}
},
{
breakpoint: 700,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
$(function(){
$('.your-class').slick({
slidesToShow: 4,
slidesToScroll: 1,
appendArrows: $('.your-class-arrow'),
prevArrow: '<button id="prev" type="button" class="btn btn-juliet"><i class="fa fa-chevron-left" aria-hidden="true"></i> Туда</button>',
nextArrow: '<button id="next" type="button" class="btn btn-juliet">Сюда <i class="fa fa-chevron-right" aria-hidden="true"></i></button>'
});
});
<div class="your-class">
<div>your content</div>
<div>your content</div>
<div>your content</div>
</div>
<div class="your-class-arrow"></div>
<!DOCTYPE html>
<html lang="ru-RU">
<head>
<meta charset="UTF-8">
<meta name="author" content="reskwer">
<title>Что-то на CodePen</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="main">
<p>Какието данные</p>
<p>Какието данные</p>
<p>Какието данные</p>
<p>Какието данные</p>
</div>
<a href="#main" id="click">
<img src="http://placehold.it/100x50" alt="img">
</a>
<a href="#" id="back">Вернуть все</a>
</body>
</html>
#main{
width: 400px;
height: 200px;
background: #eee;
border: 1px solid black;
text-align: center;
margin: 10px 0px;
}
#main p{
display: none;
}
#main:target p{
display: block;
}
#main:target + #click{
display: none;
}
#main:target ~ #back{
display: block;
}
#back{
display: none;
margin-left: 311px;
}
function display_woocommerce_order_count( $atts, $content = null ) {
$args = shortcode_atts( array(
'status' => 'completed',
), $atts );
$statuses = array_map( 'trim', explode( ',', $args['status'] ) );
$order_count = 0;
foreach ( $statuses as $status ) {
if ( 0 !== strpos( $status, 'wc-' ) ) {
$status = 'wc-' . $status;
}
$order_count += wp_count_posts( 'shop_order' )->$status;
}
ob_start();
echo number_format( $order_count );
return ob_get_clean();
}
add_shortcode( 'wc_order_count', 'display_woocommerce_order_count' );
function category_shop_func( $atts ) {
$output = '<div class="category_shop">';
$params = shortcode_atts( array( // в массиве укажите значения параметров по умолчанию
'category_id' => '', // параметр 1
), $atts );
$args = array(
'taxonomy' => 'product_cat',
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids,
'child_of' => $params['category_id']
);
$product_categories = get_terms( $args );
$count = count($product_categories);
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
$thumbnail_id = get_woocommerce_term_meta( $product_category->term_id, 'thumbnail_id', true );
$item = '<div class="catalog__category category-block">';
$item .= '<a href="' . get_term_link( $product_category ) . '" class="category-block__link">Перейти</a>';
$item .= '<img class="category-block__img" src="'. wp_get_attachment_url( $thumbnail_ids ) .'" alt="">';
$item .= '<h3 class="category-block__title">' . $product_category->name . '</h3>';
$item .= '</div>';
$output .= $item;
}
}
$output .= '</div>';
return $output;
}
add_shortcode( 'category_shop', 'category_shop_func' );
const buttonSelector = '.one-click-button';
const dataAttr = 'id';
const input = document.querySelector('#one_b_id');
const getId = el => el.dataset[dataAttr];
// или
const getId = el => el.getAttribute(`data-${dataAttr}`);
// или
const getId = el => el.attributes['data-' + dataAttr].value;
document.addEventListener('click', e => {
const button = e.target.closest(buttonSelector);
if (button) {
input.value = getId(button);
}
});
document.querySelectorAll(buttonSelector).forEach(function(n) {
n.addEventListener('click', this);
}, e => input.value = getId(e.currentTarget));
global $product;
$id = $product->id;
jQuery('.one-click-button').click(function(e) {
e.preventDefault();
jQuery(this).addClass('adding-cart');
var product_id = jQuery(this).data('id');
var ajax_url = "/wp-admin/admin-ajax.php"
jQuery.ajax ({
url: ajax_url,
type:'POST',
data:'action=oneclick&product_id=' + product_id + '&quantity=1',
success:function(results) {
// Показываем окно успешного добавления
$('.form_popup').hide();
$('#modal').css('display','inline-block');
$('.good_cart').css('display','inline-block');
document.location.href = 'http://domain.ru/oformlenie-zakaza/'; //Переход на оформление заказа
}
});
});
function oneclick() {
$product_id = $_POST['product_id'];
$variation_id = $_POST['variation_id'];
$quantity = $_POST['quantity'];
if ($variation_id) {
WC()->cart->add_to_cart( $product_id, $quantity, $variation_id );
} else {
WC()->cart->add_to_cart( $product_id, $quantity);
}
$items = WC()->cart->get_cart();
global $woocommerce;
$item_count = $woocommerce->cart->cart_contents_count; ?>
<?php die();
}
add_action('wp_ajax_oneclick', 'oneclick');
add_action('wp_ajax_nopriv_oneclick', 'oneclick');