categories – Conditional label Woocommerce archive

I’m building a webshop with WordPress and Woocommerce. On the productoverview (archive) of a productcategories I want to show a label if the product has the category ‘New’. The following code works on the product-single, but it won’t show on the productcategory-page if I add the action in content-product.php.

I used the following code to show a label on the single product page and it works as it should.

function resign_article_is_new(){

    if ( is_product() && has_term( 'Nieuw', 'product_cat' ) ) {
        echo '<p class="new-lable">New</p>';
    }
}
add_action( 'resign_new_article', 'resign_article_is_new');

When I want to show the label on the productcategory overview I used this, but the label wouldn’t appear.

do_action('resign_new_article');

Hope you can tell me what I’m doing wrong

polylang woocommerce create translation for products programmatically

polylang woocommerce create translation for products programmatically – WordPress Development Stack Exchange

I need assistance with WooCommerce single product gallery images

I need assistance with WooCommerce single product gallery images – WordPress Development Stack Exchange

php – WooCommerce – Display how many people have a product in their cart with conditional message

I’m using the following snippet to display how many people have added a product in their current cart on the Shop and Single Product pages; similar to what you see on stores like Etsy.

The snippet works as is but it would be nice to conditionally change the message depending on if there is 1 user vs. multiple people (i.e “1 person has this in their cart right now.” vs “10 people have this in their carts right now.”).

If anyone has any suggestions on the best way to handle that it would be appreciated. 🙂

function show_no_of_people_added_in_cart(){
    global $wpdb, $product;
    $in_basket = 0;
    $wc_session_data = $wpdb->get_results( "SELECT session_key FROM {$wpdb->prefix}woocommerce_sessions" );
    $wc_session_keys = wp_list_pluck( $wc_session_data, 'session_key' );
    if( $wc_session_keys ) {
        foreach ( $wc_session_keys as $key => $_customer_id ) { 
            // if you want to skip current viewer cart item in counts or else can remove belows checking
            if( WC()->session->get_customer_id() == $_customer_id ) continue;
            
            $session_contents = WC()->session->get_session( $_customer_id, array() );
            $cart_contents = maybe_unserialize( $session_contents('cart') );
            if( $cart_contents ){
                foreach ( $cart_contents as $cart_key => $item ) {
                    if( $item('product_id') == $product->get_id() ) {
                        $in_basket += 1;
                    }
                }
            }
        }
    }

    if( $in_basket ) 
        echo '<div class="in-basket">' . sprintf( __( '%d people have this in their cart', 'text-domain' ), $in_basket ) . '</div>';

}

add_action( 'woocommerce_after_shop_loop_item_title', 'show_no_of_people_added_in_cart', 11 );
add_action( 'woocommerce_single_product_summary', 'show_no_of_people_added_in_cart', 21 );

Campos do checkout disponíveis na página do produto do Woocommerce

Estou precisando tirar uma dúvida. É possível disponibilizar campos já existentes do checkout do woocommerce na página de produto. Por exemplo, gostaria de adicionar alguns campos que seriam preenchidos já não página de produto do meu woocommerce, ao clicar em Adicionar ao Carrinho o cliente seria redirecionado para checkout e automaticamente os dados seriam preenchidos sendo apenas necessário que eles preenchesse os demais dados.

O campos que precisaria seriam: Nome, Sobrenome, telefone e E-mail. Porém não encontrei nada similar na net.

I will create wordpress website for you for $125

I will create wordpress website for you

Are you looking for an awesome,extraordinary and professional wordpress full website creation?Then you are in the right place. My name is Kaniz Fathema.I can build responsive wordpress full website creation for you.I’m hardworking and professional freelancer and my aim is to provide good quality to my clients.

My Services:

  • WordPress Theme Installation & Customization
  • WordPress Plugin Installation & Customization
  • HTML5,
  • CSS3 Animation
  • Bootstap
  • Content Upload,
  • Support and Maintenance
  • Fully Responsive

Why Choose Me?

  • High-quality work
  • On-time delivery
  • 100% satisfaction assurance
  • Unlimited revisions

Yours dream wordpress website turns into reality.

I love to see my clients happy.Message me before ordering the gig to discuss and clear the requirement.

Thank you!

.

Woocommerce Email show HTML source code

I updated my Woocommerce to version 5.6.0 but since that update the emails send by Woocommerce (invoice/order updates etc) will be send as HTML-source code despite it has to send a designed template. I didn’t change anything on code, but maybe someone has a fix for this.

woocommerce offtopic – Show ‘Shop’ Link on Product Categories in yoast Breadcrumb

I have Yoast breadcrumbs setup on my WooCommerce shop but noticed something unusual. When I’m on a product the ‘Shop’ link is in the breadcrumb, but when I’m on a product category archive it isn’t. For example I get:

Home >> Category Name

How do I get it to display Home >> Shop >> Category Name?

ajax – WooCommerce event works in jQuery but not in JavaScript

I’m using WooCommerce hook added_to_cart which works perfectly in jQuery, but doesn’t work in vanilla Javascript. Both functions are running on document loaded. Here is my code reference:

JavaScript

  ajaxAddToCart: function () {
    document.body.addEventListener("click", function (e) {
        if (!e.target.classList.contains("add_to_cart_button")) return;
        
        // This event doesn't work
        document.body.addEventListener("added_to_cart", function () {
            console.log("added");
            setTimeout(function () {
                added.classList.add("button");
                added.innerHTML = `<span class="text">${wc_cart_fragments_params.i18n_view_cart}</span>
                        <span class="icon">check</span>`;
            }, 100);
        });
    });
},

jQuery

$(document).on("click", ".add_to_cart_button", function (e) {

    // This event works
    $("body").on("added_to_cart", function () {
      console.log("added");
      setTimeout(function () {
        _this.next(".added_to_cart").addClass("button");
        _this.next(".added_to_cart").html('<span class="text"></span><span class="icon">Check</span>');
      }, 100);
    });
  });

Create filter like woocommerce attribute filter for custom product page

Hi there I’ve been tasked with creating a custom filter for a product page where users can choose an attribute and it will only show those products, but I don’t really know where to start it would be like this one that woocommerce has for their all product block where it filters the products by attribute.

enter image description here

The current code I have is this where it’s getting the products and then looping through displaying each one, I’m just wondering how can I add a filter like the one above to this php file to have the same functionality (or similar)

   $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'product_cat' => 'PaidProducts' );

   $products = get_posts( $args );

   $prod_count = count($products);

   $_pf = new WC_Product_Factory(); 

   $row_num = 0;

   for ($i = 0; $i < $prod_count; $i++) {
   //Displays products here 
   }

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheap USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Best Quality USA Private Proxies