Skip to content

Instantly share code, notes, and snippets.

View kreamweb's full-sized avatar

Emanuela Antonina Castorina kreamweb

  • Kream di Emanuela Castorina
  • Acicatena (CT) - Italy
View GitHub Profile
if ( ! function_exists( 'yith_pos_customization_show_print_items_link' ) ) {
add_action( 'wp_enqueue_scripts', 'yith_pos_customization_show_print_items_link', 99 );
function yith_pos_customization_show_print_items_link() {
$js = "wp.hooks.addFilter('yith_pos_header_links', 'yith-pos/customization', (links) => {
let newLinks = [];
links.forEach( link => {
if( link.className === 'register-logout-link' ){
link.show = true;
<?php
add_action( 'woocommerce_applied_coupon', 'change_subscription_next_payment_due_date' );
add_action( 'woocommerce_removed_coupon', 'change_subscription_next_payment_due_date_on_remove_coupon' );
function change_subscription_next_payment_due_date( $coupon_code ) {
if ( 'bundle' === strtolower( $coupon_code ) ) {
change_next_billing_date( 90 );
}
}
<?php
if( defined('YITH_WCAS_VERSION')){
remove_action( 'storefront_header', 'storefront_product_search', 40 );
add_action( 'storefront_header', 'ywcas_product_search', 40 );
function ywcas_product_search(){
?>
<div class="site-search">
<?php echo do_shortcode('[yith_woocommerce_ajax_search]'); ?>
<?php if( function_exists('YWSBS_Subscription_Order')){
add_filter('ywsbs_renew_order_status', 'ywsbs_put_woo_stripe_renew_in_pending', 10, 2);
function ywsbs_put_woo_stripe_renew_in_pending( $status, $subscription ){
if( $subscription && 'stripe'===$subscription->payment_method){
$status = 'pending';
}
return $status;
}
<?php
if ( defined( 'YITH_WCAS_PREMIUM' ) ) {
add_action( 'ywcas_before_do_the_request', 'yith_wcas_query_fix' );
function yith_wcas_query_fix() {
global $yith_wcas, $wp_the_query;
remove_filter( 'posts_where', array( $yith_wcas, 'extend_search_where' ) );
remove_filter( 'posts_join', array( $yith_wcas, 'extend_search_join' ) );
phpcs --standard=WordPress templates/request-quote-view.php
#hide warning
phpcs --standard=WordPress -n templates/request-quote-view.php
#automation
phpcs --standard=WordPress --report-diff=changes.diff view-quote.php
patch -p0 -ui changes.diff
//only escape
@kreamweb
kreamweb / functions.php
Created March 6, 2020 08:56
**YITH WooCommerce Point of Sale** - Snippet to change the max number of products for search
<?php
add_filter( 'woocommerce_rest_product_object_query', 'yith_pos_extend_post_per_pages', 5, 2 );
function yith_pos_extend_post_per_pages( $args, $request ){
if ( isset( $_GET[ 'queryName' ] ) && 'yith_pos_search' === $_GET[ 'queryName' ] ) {
$args[ 'posts_per_page' ] = 20;
}
return $args;
@kreamweb
kreamweb / functions.php
Last active February 21, 2020 10:25
** YITH Point of Sale for WooCommerce** How add the Sku inside search results
<?php
add_filter( 'woocommerce_rest_prepare_product_object', 'yith_pos_custom_product_response', 20, 3 );
function yith_pos_custom_product_response( $response, $object, $request ) {
$param = $request->get_param( 'queryName' );
if ( $param == 'yith_pos_search' ) {
$result = $response->data;
$result['name'] .= empty($result['sku']) ? '' : ' - ' . $result['sku'];
$response->data = $result;
@kreamweb
kreamweb / functions.php
Last active February 21, 2020 09:32
[POS] Enable options multistock to all products
<?php
add_action( 'init', 'yith_pos_add_meta_to_products' );
function yith_pos_add_meta_to_products() {
$option = get_option( 'yith_pos_stock_product_enabled', 'no' );
if ( $option === 'no' ) {
$products = wc_get_products( array( 'limit' => - 1 ) );
if ( $products ) {
@kreamweb
kreamweb / functions.php
Last active May 16, 2023 20:35
**YITH Point of Sale for WooCommerce** Hide cash in hand to cashiers
<?php
if ( defined( 'YITH_POS_VERSION' ) && ! function_exists( 'yith_pos_add_user_role_to_pos_class' ) ) {
add_filter( 'yith_pos_body_classes', 'yith_pos_add_user_role_to_pos_class' );
function yith_pos_add_user_role_to_pos_class( $body_class ) {
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
$body_class = array_merge( $body_class, (array) $user->roles );
}