Skip to content

Instantly share code, notes, and snippets.

View artikus11's full-sized avatar
🥕
Create plugins

Artem Abramovich artikus11

🥕
Create plugins
View GitHub Profile
jQuery( document ).ready( function( $ ) {
$( document ).on( 'click', '.plus, .minus', function() {
// Get values
var $qty = $( this ).closest( '.quantity' ).find( '.qty' ),
currentVal = parseFloat( $qty.val() ),
max = parseFloat( $qty.attr( 'max' ) ),
min = parseFloat( $qty.attr( 'min' ) ),
step = $qty.attr( 'step' );
@artikus11
artikus11 / woocommerce-functions.php
Created June 11, 2017 21:12
Вывод количества товаров к корзине с обновление по ajax
add_action( 'mobile_cart', 'artabr_header_card' );// хук должен быть где-то в шапке или просто функцию выводите в нужном месте
function artabr_header_card() {
global $woocommerce;
$count = $woocommerce->cart->get_cart_contents_count();
//$count = get_cart_contents_count();
?>
<a class="cart-link" href="<?php echo wc_get_cart_url(); ?>" title="Смотреть корзину">
<!--<span class="dashicons dashicons-cart"></span>-->
<?php if ( $count > 0 ) : ?>
@artikus11
artikus11 / functions.php
Created July 24, 2023 19:24
Отключение лайтбокса и зума на странице товара WooCommerce
add_action( 'after_setup_theme', 'art_remove_wc_lightbox_zoom', 100 );
function art_remove_wc_lightbox_zoom() {
remove_theme_support( 'wc-product-gallery-lightbox' );
remove_theme_support( 'wc-product-gallery-zoom' );
}
.product-content--meta--list {
margin: 0;
padding: 0;
}
.product-content--meta--list tbody {
display: grid;
gap: 12px;
}
/**
* Вывод избранных атрибутов в карточке товара
*
* @param $product
*
* @return array
*/
public function get_attributes_to_product( $product ) {
$product_attributes = [];
@artikus11
artikus11 / wp_remove_attachments_old.sh
Created March 21, 2023 16:26 — forked from zevilz/wp_remove_attachments.sh
Remove old WP attachments
#!/bin/bash
while true; do
POSTS=$(wp db query 'SELECT ID FROM wp_posts WHERE post_type="attachment" AND post_date < "2022-06-05" LIMIT 10000;' --skip-column-names | paste -s -d ' ' -)
if ! [ -z "$POSTS" ]; then
wp post delete $POSTS --force
else
exit 0
fi
done
@artikus11
artikus11 / functions.php
Last active February 23, 2023 13:29
Функция проверки существования товара на странице. Проверяет на шорткод, блок и шатные страницы архивов
function has_product(): array {
$has_product_page = is_shop() || is_product_category() || is_product_tag() || is_product();
global $post;
if ( ! $post ) {
return [ false, false, false ];
}
@artikus11
artikus11 / snippet-woo.php
Last active January 23, 2023 22:20
Woocommerce. Изменение HTML полей на странице оформления заказа (чекаут)
add_filter( 'woocommerce_form_field', 'art_change_woocommerce_form_field', 10, 4 );
/**
* Изменение хтмл полей
*
* @param $field
* @param $key
* @param $args
* @param $value
*
* @testedwith WooCommerce 7.0
function art_adding_attributes( $post_id, $xml_node ) {
// Ограничиваем работу сниппета нужным импортом
$import_id = ( $_GET['id'] ?? ( isset( $_GET['import_id'] ) ? $_GET['import_id'] : 'new' ) );
$attributes_from_string = [];
if ( ( '31' === $import_id || '26' === $import_id ) && $xml_node->dimensions ) {
$sep = '/';
<?php
class Blow_Roles {
public function __construct() {
$this->hooks();
}