Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter dave031284

    (@dave031284)

    I’ve managed to get this working

    // reply to all email address

    add_filter( ‘woocommerce_email_headers’, ‘reply_email_address’, 10, 2 );

    function reply_email_address ( $headers ) {
    $headers = array(‘Reply-To: email name <[email protected]>’);

    return $headers;
    }

    but this apply s to all emails when i only want it to apply to admin new order emails. I’ve created the below but it’s not working. can someone please help

    // Change WooCommerce reply to email address for new order email only

    add_filter( ‘woocommerce_email_headers’, ‘wc_change_email_reply_address’, 10, 3 );

    function wc_change_email_reply_address ( $headers, $obj ) {
    // For Admin New Order Emails
    if ( is_a( $obj, ‘WC_Email_New_Order’ ) ) {
    $headers = array(‘Reply-To: email name <[email protected]>’);
    }

    return $headers;
    }

    Thread Starter dave031284

    (@dave031284)

    any updates on this?

    Thread Starter dave031284

    (@dave031284)

    Anyone have any ideas how to achieve this?

    Hi,

    I’m now having a similar issue. I have the theme on a multisite and all was working fine. I created a new multisite and with it a child theme for wootique however the featured products arn’t showing. The versions are all the same on every site so not sure of the issue. Can you help?

    If you could do product availability by time that would be great.

    I run a food ordering site, so being able to restrict breakfast items to breakfast time etc would be great. Either by product or by product category. That would an amazing feature.

    Thread Starter dave031284

    (@dave031284)

    resolved, due to cache issue.

    Hi,

    I get the same issue. I have used this for a fw months and worked great. however last week a got loads of failed to subscribe emails. This resolved itself but now when setting up a new site my API key isn’t being accepted.
    Looking on the website it says

    “IMPORTANT: You must upgrade to version 2.X by December 31, 2016 as prior versions of the MailChimp API will stop working at that point.” On the offical plugins page I have the latest version.

    Please can you help. I seem to be able to still sign up new customers when they opt in even though the API says failed but i can’t select the groups etc.

    Thread Starter dave031284

    (@dave031284)

    I have this the following but doesn’t seem to work quite right

    function is_product_the_same_cat($valid, $product_id, $quantity) {
    global $woocommerce;
    // start of the loop that fetches the cart items
    foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
    $_product = $values[‘data’];
    $terms = get_the_terms( $_product->id, ‘product_cat’ );
    $target_terms = get_the_terms( $product_id, ‘product_cat’ ); //get the current items
    foreach ($terms as $term) {
    $cat_ids[] = $term->term_id; //get all the item categories in the cart
    }
    foreach ($target_terms as $term) {
    $target_cat_ids[] = $term->term_id; //get all the categories of the product
    }
    }
    $same_cat = array_intersect($cat_ids, $target_cat_ids); //check if they have the same category
    if(count($same_cat) > 0) return $valid;
    else {
    wc_add_notice( ‘This product is in another category!’, ‘error’ );
    return false;
    }
    }
    add_filter( ‘woocommerce_add_to_cart_validation’, ‘is_product_the_same_cat’,10,3);

    ############## and also ###################

    // Enforce single parent category items in cart at a time based on first item in cart
    function get_product_top_level_category ( $product_id ) {

    $product_terms = get_the_terms ( $product_id, ‘product_cat’ );
    $product_category = $product_terms[0]->parent;
    $product_category_term = get_term ( $product_category, ‘product_cat’ );
    $product_category_parent = $product_category_term->parent;
    $product_top_category = $product_category_term->term_id;

    while ( $product_category_parent != 0 ) {
    $product_category_term = get_term ( $product_category_parent, ‘product_cat’ );
    $product_category_parent = $product_category_term->parent;
    $product_top_category = $product_category_term->term_id;
    }

    return $product_top_category;
    }

    add_filter ( ‘woocommerce_before_cart’, ‘restrict_cart_to_single_category’ );
    function restrict_cart_to_single_category() {
    global $woocommerce;
    $cart_contents = $woocommerce->cart->get_cart( );
    $cart_item_keys = array_keys ( $cart_contents );
    $cart_item_count = count ( $cart_item_keys );

    // Do nothing if the cart is empty
    // Do nothing if the cart only has one item
    if ( ! $cart_contents || $cart_item_count == 1 ) {
    return null;
    }

    // Multiple Items in cart
    $first_item = $cart_item_keys[0];
    $first_item_id = $cart_contents[$first_item][‘product_id’];
    $first_item_top_category = get_product_top_level_category ( $first_item_id );
    $first_item_top_category_term = get_term ( $first_item_top_category, ‘product_cat’ );
    $first_item_top_category_name = $first_item_top_category_term->name;

    // Now we check each subsequent items top-level parent category
    foreach ( $cart_item_keys as $key ) {
    if ( $key == $first_item ) {
    continue;
    }
    else {
    $product_id = $cart_contents[$key][‘product_id’];
    $product_top_category = get_product_top_level_category( $product_id );

    if ( $product_top_category != $first_item_top_category ) {
    $woocommerce->cart->set_quantity ( $key, 0, true );
    $mismatched_categories = 1;
    }
    }
    }

    // we really only want to display this message once for anyone, including those that have carts already prefilled
    if ( isset ( $mismatched_categories ) ) {
    echo ‘<p class=”woocommerce-error”>Only one category allowed in cart at a time.<br />You are currently allowed only ‘.$first_item_top_category_name.’ items in your cart.<br />To order a different category empty your cart first.</p>’;
    }
    }

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