Forum Replies Created

Viewing 15 replies - 31 through 45 (of 434 total)
  • WP SITES

    (@wordpresssites)

    One thing i know and thats Stripe and PayPal are harsh on eCommerce sites selling peptides.

    WP SITES

    (@wordpresssites)

    You can add a custom column like this which includes products based on all statuses.

    add_filter('manage_edit-product_cat_columns', 'custom_product_cat_columns');
    function custom_product_cat_columns($columns) {
    $columns['custom_count'] = __('All', 'woocommerce');
    unset($columns['count']); // Remove default count column
    return $columns;
    }

    add_filter('manage_product_cat_custom_column', 'custom_product_cat_column_content', 10, 3);
    function custom_product_cat_column_content($content, $column, $term_id) {
    if ($column === 'custom_count') {
    $statuses = ['publish', 'draft', 'pending'];
    $count = 0;

    foreach ($statuses as $status) {
    $query = new WP_Query([
    'post_type' => 'product',
    'post_status' => $status,
    'tax_query' => [
    [
    'taxonomy' => 'product_cat',
    'field' => 'term_id',
    'terms' => $term_id,
    ]
    ],
    'fields' => 'ids',
    'posts_per_page' => -1,
    ]);

    $count += $query->found_posts;
    }

    // Link to filtered products by term ID
    $term = get_term($term_id, 'product_cat');
    $url = admin_url('edit.php?post_type=product&product_cat=' . $term->slug);
    $content = '<a href="' . esc_url($url) . '">' . intval($count) . '</a>';
    }
    return $content;
    }
    WP SITES

    (@wordpresssites)

    add_filter( 'woocommerce_product_categories_widget_args', 'show_only_parent_product_categories' );
    function show_only_parent_product_categories( $args ) {
    $args['parent'] = 0; // Show only top-level categories
    return $args;
    }

    See line 294 in wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-categories.php

    Tested and works.

    You can add the code to the end of your child themes functions file or custom code snippets plugin.

    FYI The widget name is Product Categories not Product Categories List Widget.

    WP SITES

    (@wordpresssites)

    $category_ids = array(4, 7, 10); // Replace with your desired category IDs

    foreach ( $category_ids as $cat_id ) {
    $args = array(
    'post_type' => 'post',
    'posts_per_page' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    'cat' => $cat_id,
    );

    $query = new WP_Query( $args );

    if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
    $query->the_post();
    echo '<h3>Category: ' . get_cat_name( $cat_id ) . '</h3>';
    echo '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
    }
    wp_reset_postdata();
    }
    }
    Thread Starter WP SITES

    (@wordpresssites)

    Thanks for your help with this shahzeen. Please mark as resolved even though i used code to make the field display. I’ll work out what the problem is at another time.

    Thread Starter WP SITES

    (@wordpresssites)

    It shows but nothing happens when i click to insert. I had to use code to display it.

    Its a bug.

    I tested on 3 different sites using different themes and only WC active. TT4 and TT5

    WP SITES

    (@wordpresssites)

    Would strongly advise against using page builders especially when using block themes.

    WP SITES

    (@wordpresssites)

    Try this in functions.php and see what it gets.

    add_action('wp_footer', 'dump_full_pricing_for_current_product');
    function dump_full_pricing_for_current_product() {
    if ( ! is_product() || ! current_user_can('administrator') ) return;

    global $product, $woocommerce;

    if ( $product && $product->is_type( 'variable' ) ) {
    $variations = $product->get_available_variations();

    echo '<pre>';
    foreach ( $variations as $variation_data ) {
    $variation = wc_get_product( $variation_data['variation_id'] );

    $price_excl_tax = wc_get_price_excluding_tax( $variation );
    $price_incl_tax = wc_get_price_including_tax( $variation );

    // Simulated shipping cost placeholder (actual shipping can't be calculated without full cart + address)
    $shipping_cost = 'Depends on shipping method & address';

    // Simulated fees placeholder (fees are usually added via custom plugins or in cart context)
    $fees = 'Depends on cart-level conditions';

    $data = [
    'variation_id' => $variation->get_id(),
    'attributes' => $variation->get_attributes(),
    'regular_price' => $variation->get_regular_price(),
    'sale_price' => $variation->get_sale_price(),
    'price' => $variation->get_price(),
    'price_excl_tax' => wc_price( $price_excl_tax ),
    'price_incl_tax' => wc_price( $price_incl_tax ),
    'simulated_shipping' => $shipping_cost,
    'simulated_fees' => $fees,
    ];

    var_dump( $data );
    }
    echo '</pre>';
    }
    }
    Thread Starter WP SITES

    (@wordpresssites)

    I ended up fixing it myself in my own plugin but thanks anyway.

    Thread Starter WP SITES

    (@wordpresssites)

    Worked it out. You need to click the image within the cross sells block and then use the product image block settings.

    • This reply was modified 1 year, 2 months ago by WP SITES.
    • This reply was modified 1 year, 2 months ago by WP SITES.
    WP SITES

    (@wordpresssites)

    You could create a shortcode :

    function apple_music_shortcode() {
    ob_start();
    the_field('apple_music_embed');
    return ob_get_clean();
    }
    add_shortcode('apple_music', 'apple_music_shortcode');
    WP SITES

    (@wordpresssites)

    Thread Starter WP SITES

    (@wordpresssites)

    Not fixed.

    WP SITES

    (@wordpresssites)

    There’s a cost of goods extension for this also https://woocommerce.com/document/cost-of-goods-sold/

    WP SITES

    (@wordpresssites)

    Add some code to your child themes functions file for the products purchase price.

    add_action( 'woocommerce_product_options_general_product_data', 'add_purchase_price_field' );
    function add_purchase_price_field() {
    woocommerce_wp_text_input( array(
    'id' => '_purchase_price',
    'label' => __( 'Purchase Price', 'woocommerce' ),
    'description' => __( 'Enter the purchase price of the product.', 'woocommerce' ),
    'desc_tip' => true,
    'type' => 'number',
    'custom_attributes' => array(
    'step' => '0.01',
    'min' => '0'
    ),
    ));
    }

    add_action( 'woocommerce_admin_process_product_object', 'save_purchase_price_field' );
    function save_purchase_price_field( $product ) {
    if ( isset( $_POST['_purchase_price'] ) ) {
    $product->update_meta_data( '_purchase_price', sanitize_text_field( $_POST['_purchase_price'] ) );
    }
    }
Viewing 15 replies - 31 through 45 (of 434 total)