CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other

17 May, 2022

Limit of log line written to Apache Errorlog from mod php error_log

 Programing Coderfunda     May 17, 2022     php     No comments   

 Answer

0

If you really need to log errors more than 1024 the you need to explicitly add

log_errors_max_len = 0

Beacuse the default is 1024 and 0 allows to not apply any maximum length at all. Please read the log for more info.

https://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors-max-len


Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Filter WooCommerce products with post__in and additional meta queries

 Programing Coderfunda     May 17, 2022     php     No comments   

 

2 Answers

0
$on_sale_product_ids = wc_get_product_ids_on_sale();

$queried_products = wc_get_products(array(
    'limit' => 1000,
    'orderby' => 'id',
    'order' => 'asc',
    'price_and_stock' => true,
));
$on_sale_products = wc_get_products(array('include' => array_values($on_sale_product_ids) , 'limit' => count($on_sale_product_ids)) );

$total_products = array_merge($on_sale_products,$queried_products );

Add below code snippet for price_and_stock combination query.

function handle_custom_query_var( $query, $query_vars ) {
    if ( ! empty( $query_vars['price_and_stock'] ) ) {
        $query['meta_query'][] =    array( 'relation' => 'AND',
    'price' => array(
        'key' => '_price',
        'value' => 9,
        'compare' => '<',
        'type' => 'numeric'
    ),
    'stock_status' => array(
        'key' => '_stock_status',
        'value' => 'instock',
        'compare' => '=',
    )
            );
    }

    return $query;
}
add_filter( 'woocommerce_product_data_store_cpt_get_products_query', 'handle_custom_query_var', 10, 2 );

More details on the custom query can be found here

== Alternate ==

Note: you cannot combine post__in and post__not_in in the same query. post__in and post__not_in are mutually exclusive.

$meta_query = array(
                'relation' => 'AND',
                'price' => array(
                    'key' => '_price',
                    'value' => 9,
                    'compare' => '<',
                    'type' => 'numeric'
                ),
                'stock_status' => array(
                    'key' => '_stock_status',
                    'value' => 'instock',
                    'compare' => '=',
                ),
            );
        
            $args = array(
                'post_type' => array('product', 'product_variation'),
                'posts_per_page' => 1000,
                'return' => 'ids',
                'post__in' => wc_get_product_ids_on_sale(),
                'meta_query' => $meta_query // this contains the price under X query
            );
            $total_products = wc_get_products($args);
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

WooCommerce shop loop random array function not same values after each other

 Programing Coderfunda     May 17, 2022     php     No comments   

 

Answers

2

There are several ways, you can store the value temporarily via a cookie, sessions, transients, meta data.. but personally I would go for a global variable so that no database requests are needed.

So you get:

function random_result() {
    // Input
    $input = array( '<img src="/wp-content/uploads/2022/01/banner-001.svg">', '<img src="/wp-content/uploads/2022/01/banner-002.svg">', '<img src="/wp-content/uploads/2022/01/banner-003.svg">' );

    // NOT isset (result) OR NOT isset (counter)
    if ( ! isset( $GLOBALS['result'] ) || ! isset( $GLOBALS['counter'] ) ) {
        // Shuffle an array
        shuffle( $input );

        // Globals
        $GLOBALS['result'] = $input;
        $GLOBALS['counter'] = 0;
    } else {
        // Plus 1
        $GLOBALS['counter'] += 1;
    }

    // Store
    $counter = $GLOBALS['counter'];

    // Limit is reached, reset
    if ( $counter == ( count( $input ) - 1 ) ) {
        unset( $GLOBALS['counter'] );
    }

    return $GLOBALS['result'][$counter];
}

function action_woocommerce_shop_loop() {
    // Variables
    global $wp_query;
    
    // Add content every X product
    if ( (  $wp_query->current_post % 7 ) ==  0 && $wp_query->current_post !=  0 ) {
        // Call function, display result
        echo random_result();
    }
}
add_action( 'woocommerce_shop_loop', 'action_woocommerce_shop_loop' );
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Posts Older Posts Home

Meta

Popular Posts

  • Write API Integrations in Laravel and PHP Projects with Saloon
    Write API Integrations in Laravel and PHP Projects with Saloon Saloon  is a Laravel/PHP package that allows you to write your API integratio...
  • Credit card validation in laravel
      Validation rules for credit card using laravel-validation-rules/credit-card package in laravel Install package laravel-validation-rules/cr...
  • iOS 17 Force Screen Rotation not working on iPAD only
    I have followed all the links on Google and StackOverFlow, unfortunately, I could not find any reliable solution Specifically for iPad devic...
  • C++ in Hindi Introduction
    C ++ का परिचय C ++ एक ऑब्जेक्ट ओरिएंटेड प्रोग्रामिंग लैंग्वेज है। C ++ को Bjarne Stroustrup द्वारा विकसित किया गया था। C ++ में आने से पह...
  • Send message via CANBus
    After some years developing for mobile devices, I've started developing for embedded devices, and I'm finding a new problem now. Th...

Categories

  • Ajax (26)
  • Bootstrap (30)
  • DBMS (42)
  • HTML (12)
  • HTML5 (45)
  • JavaScript (10)
  • Jquery (34)
  • Jquery UI (2)
  • JqueryUI (32)
  • Laravel (1017)
  • Laravel Tutorials (23)
  • Laravel-Question (6)
  • Magento (9)
  • Magento 2 (95)
  • MariaDB (1)
  • MySql Tutorial (2)
  • PHP-Interview-Questions (3)
  • Php Question (13)
  • Python (36)
  • RDBMS (13)
  • SQL Tutorial (79)
  • Vue.js Tutorial (68)
  • Wordpress (150)
  • Wordpress Theme (3)
  • codeigniter (108)
  • oops (4)
  • php (853)

Social Media Links

  • Follow on Twitter
  • Like on Facebook
  • Subscribe on Youtube
  • Follow on Instagram

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

  • September (100)
  • August (50)
  • July (56)
  • June (46)
  • May (59)
  • April (50)
  • March (60)
  • February (42)
  • January (53)
  • December (58)
  • November (61)
  • October (39)
  • September (36)
  • August (36)
  • July (34)
  • June (34)
  • May (36)
  • April (29)
  • March (82)
  • February (1)
  • January (8)
  • December (14)
  • November (41)
  • October (13)
  • September (5)
  • August (48)
  • July (9)
  • June (6)
  • May (119)
  • April (259)
  • March (122)
  • February (368)
  • January (33)
  • October (2)
  • July (11)
  • June (29)
  • May (25)
  • April (168)
  • March (93)
  • February (60)
  • January (28)
  • December (195)
  • November (24)
  • October (40)
  • September (55)
  • August (6)
  • July (48)
  • May (2)
  • January (2)
  • July (6)
  • June (6)
  • February (17)
  • January (69)
  • December (122)
  • November (56)
  • October (92)
  • September (76)
  • August (6)

Loading...

Laravel News

Loading...

Copyright © CoderFunda | Powered by Blogger
Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda