Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter robfaas

    (@robfaas)

    May login is not necassary. I just discoved a template-functions.php file that maybe has some outdated code. This is made by the original webbuilder, to adjust the appearence for matching this page: https://www.lezenopschool.nl/bestelformulieren/
    So, the header section and sort-by indeed should be hiddend, but the select all should be visible. It was, untill some time agoo. This is the .php:
    /**

    • for loading table header – columns
      • @param atts from shortcode attributes
    • @uses mpc_get_table_columns filter to modifiy it
      • ** (future update) hide table header section (option)
        */

    if( !function_exists( ‘mpc_table_header’ ) ){
    function mpc_table_header( $atts ){
    global $mpc_query;

        $columns = array();
    
        if( $atts['image'] ) $columns['wmc_ct_image'] = 'Image';
        $columns['wmc_ct_product'] = 'Product';
        $columns['wmc_ct_price'] = 'Price';
        if( $mpc_query['has_variation'] ) $columns['wmc_ct_variation'] = 'Variation';
        $columns['wmc_ct_quantity'] = 'Quantity';
        $columns['wmc_ct_buy'] = 'Toevoegen <input type="checkbox" name="all" id="checkall" />';
    
        // hook for modifying columns
        $columns = apply_filters( 'mpc_get_table_columns', $columns );
    
        $mpc_query['columns'] = $columns;
    
        $html = '';
    
        if( !empty( $columns ) )
            foreach( $columns as $key => $name )
                $html .= sprintf( '<th for="%s" class="product-%s">%s</th>', str_replace('wmc_ct_', '', $key ), str_replace('wmc_ct_', '', $key ), get_option( $key ) ? get_option( $key ) : $name );
    
        echo __( sprintf( '<thead><tr>%s</tr></thead>', $html ), 'mpc' );
    }

    }

    /**

    • displays product title in the table
      • @param product – WC object
    • @param atts – shotcode attributes
    • @uses atts[‘link’] can be true/false to show product title with/without single product link
    • @uses atts[‘description’] can also be true/false, shows product short description or not
      */

    if( !function_exists( ‘mpc_product_title’ ) ){
    function mpc_product_title( $product, $atts ){
    $html = ”;

        $html = sprintf( '%s', esc_html( $product->get_title() ) );
    
        if( $atts['link'] == true )
            $html = sprintf( '<a href="%s">%s</a>', esc_url( $product->get_permalink() ), $html );
    
        if( $atts['description'] == true ){
            $html .= sprintf( ' <div class="woocommerce-product-details__short-description"><p>%s</p></div>', wp_strip_all_tags( do_shortcode( $product->get_short_description() ? $product->get_short_description() : $product->get_description() ) ) );
        }
    
        echo __( sprintf( '<td for="title" class="product-name"><div class="mpc-product-title">%s</div></td>', $html ), 'mpc' );
    }

    }

    /**

    • displays product price (range for variable products too)
      • @param product – WC object
        */

    if( !function_exists( ‘mpc_product_price’ ) ){
    function mpc_product_price( $product ){
    $html = ”;

        if( $product->is_type( 'variable' ) )
            $html = sprintf( '<div class="mpc-single-price" style="display:none;">%s</div>', mpc_currency_total() );
    
        echo __( sprintf( '<td for="price" class="product-price">%s<div class="mpc-range">%s</div></td>', $html, $product->get_price_html() ), 'mpc' );
    }

    }

    /**

    • displays product image
      • @param product – WC object
    • NO GALLERY SUPPORT YET
      */

    if( !function_exists( ‘mpc_product_image’ ) ){
    function mpc_product_image( $product ){
    $image_id = $product->get_image_id();

        $full = wp_get_attachment_image_url( $image_id, 'full' );
        $thumbnail = wp_get_attachment_image_url( $image_id, 'thumbnail' );
    
        // for empty product image use default woocommerce placeholder image
        if( empty( $thumbnail ) || $thumbnail == '' ){
            $thumbnail = home_url() . '/wp-content/uploads/woocommerce-placeholder-150x150.png';
            if( !file_exists( $thumbnail ) )
                $thumbnail = home_url() . '/wp-content/uploads/woocommerce-placeholder.png';
        }
    
        if( empty( $full ) || $full == '' )
            $full = home_url() . '/wp-content/uploads/woocommerce-placeholder.png';
    
        echo __( sprintf( '<td for="image" class="product-image" data-pimg-thumb="%s" data-pimg-full="%s"><img width="300" height="254" src="%s" class="mpc-product-image attachment-woocommerce_thumbnail size-woocommerce_thumbnail" alt="" data-fullimage="%s"></td>', esc_url( $thumbnail ), esc_url( $full ), esc_url( $thumbnail ), esc_html( $full ) ) , 'mpc' );
    }

    }

    /**

    • displays quantity selector
      • @uses hook to mofidy minimum and maximum quantity
        */

    if( !function_exists( ‘mpc_product_quantity’ ) ){
    function mpc_product_quantity( $product ){
    $numbers = array(
    ‘min’ => 1,
    ‘max’ => 0
    );

        // filter minimum or maximum value
        $nmbers = apply_filters( 'mpc_get_product_quantity', $numbers );
    
        // override max quantity if it's sold individually
        if( $product->is_sold_individually() ){
            $numbers['max'] = 1;
    
            // change minimum if it's not 1
            if( $numbers['min'] > 1 ) $numbers['min'] = 1;
        }
    
        /**
         * although we skip product if it's not in stock, we need to check if the order amount is within the remaining stock amount
         * actually, this needs to be done per variation and handled with javaScript
         * 
         * in this scope, only handled for simple products only
         */
        $current_stock = '';
        if( $product->get_type() == 'simple' ){
            $stock_quantity = $product->get_stock_quantity();
            if( !empty( $stock_quantity ) ) $current_stock = sprintf( ' data-current_stock="%d"', $stock_quantity );
        }
    
        $max = '';
        if( $numbers['max'] > 0 )
            $max = sprintf( ' max="%d"', $numbers['max'] );
    
        $html = sprintf(
            '<td for="quantity" class="product-quantity"><div class="quantity"><input type="number" class="input-text qty text" step="1" min="%d"%s name="quantity%s" value="1" title="Quantity" size="4" inputmode="numeric"%s></div></td>',
            $numbers['min'],
            $max,
            $product->get_id(),
            $current_stock
        );
    
        echo __( $html, 'mpc' );
    }

    }

    /**

    • display add to cart checkbox
      • @uses mpc_modify_cart_content to modify it’s content
        */

    if( !function_exists( ‘mpc_product_cart_checkbox’ ) ){
    function mpc_product_cart_checkbox( $product, $atts ){
    $html = ”;

        if( is_array( $atts['selected'] ) && in_array( $product->get_id(), $atts['selected'] ) )
            $html .= sprintf( '<input type="checkbox" name="product_ids[]" class="toevoegcheckje" value="%d" checked="checked" data-price="%s">', $product->get_id(), $product->get_price() );
        else
            $html .= sprintf( '<input type="checkbox" name="product_ids[]" class="toevoegcheckje" value="%d" data-price="%s">', $product->get_id(), $product->get_price() );
    
        $html = apply_filters( 'mpc_modify_cart_content', $html, $product, $atts );
    
        echo __( sprintf( '<td for="buy" class="product-select">%s</td>', $html ), 'mpc' );
    }

    }

    /**

    • for displaying pagination text or status
      • example, Showing 34 – 40 / 150
      • @uses pagination_text attribute, which can be changed from the MPC settings
    • */
      if( !function_exists( ‘mpc_pagination_text’ ) ){
      function mpc_pagination_text( $atts ){
      if( $atts[‘pagination’] == false ) return ”; global $mpc_query; if( $mpc_query['hide_pagination_text'] == 'no' && $mpc_query['total'] > $atts['limit'] ){if( isset( $_GET['page'] ) ) $page = (int) $_GET['page']; else $page = 1; $current_range = ''; if( $mpc_query['total'] &gt; $atts['limit'] ) $current_range = ( ( $page - 1 ) * $atts['limit'] + 1 ) . ' - ' . ( $page * $atts['limit'] ); else $current_range = ( ( $page - 1 ) * $atts['limit'] + 1 ) . ' - ' . $mpc_query['total']; echo __( sprintf( '&lt;div class="mpc-product-range"&gt;&lt;p&gt;%s &lt;strong&gt;&lt;span class="ranges"&gt;%s&lt;/span&gt; / &lt;span class="max_product"&gt;%d&lt;/soan&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;', $mpc_query['pagination_text'], $current_range, $mpc_query['total'] ), 'mpc' );} }
      }

    /**

    • Current with adjacent two numbers, first and last
    • */
      function mpc_table_pagination( $atts ){
      global $mpc_query; if( $mpc_query[‘total’] > $atts[‘limit’] ){
      $html = ”; if( $mpc_query['max_page'] > 5 ){ $html .= sprintf( '<span class="current">1</span><span>2</span> ... <span>%d</span>', $mpc_query['max_page'] ); }else{ for( $i = 1; $i <= $mpc_query['max_page']; $i++ ){ if( $i == 1 ) $html .= sprintf( '<span class="current">%d</span>', $i ); else $html .= sprintf( '<span>%d</span>', $i ); } } echo __( sprintf( '<div class="mpc-pagination"><div class="mpc-inner-pagination"><div class="mpc-pagenumbers" data-max_page="%d">%s</div><div class="table-query" data-table_query="%s" data-table_atts="%s"></div></div></div>', $mpc_query['max_page'], $html, wc_esc_json( wp_json_encode( $mpc_query['query'] ) ), wc_esc_json( wp_json_encode( $atts ) ) ), 'mpc' ); }
      }

    /**

    • display product variation attributes
      • hides those options with stock out status
      • @param $product – WC_Product_Object

    • */

    if( !function_exists( ‘mpc_product_variations’ ) ){
    function mpc_product_variations( $product ){
    $html = ”;

        if( $product->is_type( 'variable' ) ) {
    
            // collect product attributes and their respective data for frontend js handle
            $variation_data = mpc_get_variation_data( $product );
            if( $variation_data ){
    
                /**
                 * save variation data for handling at user level
                 */
                $html .= sprintf(
                    '<div id="row-variation-data" data-variation_data="%s"></div>',
                    wc_esc_json( wp_json_encode( $variation_data ) )
                );
            }
    
            // default product attributes - if any of them is selected pre-defined
            $default_attributes = $product->get_default_attributes();
    
            // product attributes
            $attributes = $product->get_variation_attributes();
    
            if( !empty( $attributes ) && is_array( $attributes ) ){
                foreach ( $attributes as $name => $options ){
    
                    // skip, if it's not in stock
                    // if( ! mpc_if_variation_in_stock( $product, $name, $options ) ) continue; 
    
                    $sn = sanitize_title( $name );
                    if( strpos( $sn, 'pa_' ) !== false ){
                        $terms = wc_get_product_terms( $product->get_id(), $name, array( 'fields' => 'all', ) );
    
                        // sort variation attributes
                        $options = mpc_sort_variation_options( $product, $sn, $options, $terms );
                    }
    
                    if ( is_array( $options ) ){
                        $tmp_html = '';
    
                        foreach( $options as $option ){
    
                            // skip if this specific option is out of scope
                            if( mpc_if_variation_in_stock( $product, $name, $option ) ){
    
                                $is_selected = '';
                                if( isset( $default_attributes[$sn] ) && $default_attributes[$sn] == $option ) $is_selected = ' selected="selected"';
    
                                $tmp_html .= sprintf(
                                    '<option value="%s"%s>%s</option>',
                                    esc_attr( $option ),
                                    $is_selected,
                                    esc_html( apply_filters( 'woocommerce_variation_option_name', $option, null, $name, $product ) )
                                );
                            }
                        }
    
                        $html .= sprintf(
                            '<div class="variation-group"><label>%s</label><select id="%s" name="attribute_%s" data-attribute_name="attribute_%s"><option value="">Choose an option&hellip;</option>%s</select></div>',
                            wc_attribute_label( $name ),
                            esc_attr( $sn ),
                            $sn.$product->get_id(),
                            $sn,
                            $tmp_html
                        );
                    }
                }
            }
    
    
        }else {
            $html .= sprintf( '<span data-price="%s">N/A</span>', $product->get_price() );
        }
    
        echo __( sprintf( '<td for="variation" class="product-variation">%s</td>', $html ), 'mpc' );
    }

    }

    Thread Starter robfaas

    (@robfaas)

    Maybe also check this page with one table: https://www.lezenopschool.nl/testprodtable/

    Thread Starter robfaas

    (@robfaas)

    Anybody? Please, would appreciate help…

    Thread Starter robfaas

    (@robfaas)

    Thanks! Would be better when it could be removed by closing x, but this will do for now.

    • This reply was modified 3 years ago by robfaas.
    Thread Starter robfaas

    (@robfaas)

    Ofcourse it’s working fine there! I wrote: ‘Went back to 6.1.6 and list is showing again.’
    I will try updating from 6.1.6 to 6.2.5 one of these days and let you know.

    I have the same issue. Clearing cache is not helping.

Viewing 6 replies - 1 through 6 (of 6 total)