Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter oakwoodmedia

    (@oakwoodmedia)

    I have been playing about with this code but cannot seem to get it to work

    add_filter( 'woocommerce_product_get_shipping_class_id', 'show_shipping_class_to_specific_users', 10, 2 );
    
    function show_shipping_class_to_specific_users( $class_id, $product ) {
        $customer_id = get_current_user_id(); // Get the ID of the currently logged-in customer
        $allowed_customer_ids = array( 1, 2, 3 ); // Replace with the IDs of the customers who are allowed to see this shipping class
    
        if ( ! in_array( $customer_id, $allowed_customer_ids ) ) {
            return false; // Return false to hide the shipping class if the customer is not allowed to see it
        }
    
        return $class_id;
    }
    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Thanks for the reply the code i was using is below.

    I am wanting to hide the “ship to a different address” link and only show it to specific users, currently i was using customer roles. The code below completely removes the shipping section and i was having issues with the customers default shippiung address not coming through (only the billing address). Thanks

    // Christopher's Hide Shipping to Link for users
    add_action('init', 'unset_shipping_address' );
    function unset_shipping_address() {
    // user roles
        $user_roles = array('bronze', 'silver', 'platinum', 'gold', 'cc004592', 'cc002901', 'cc004340', 'cc003477', 'cc003419', 'cc003263', 'cc003099', 'cc003091', 'cc003087', 'cc003046', 'cc002842', 'cc002594', 'cc002207', 'cc001767', 'cc001757', 'cc001188', 'cc002731', 'cc002962', 'cc002317', 'cc003459', 'cc002593', 'cc001396', 'cc002702', 'cc005239');
    
        // Check user roles to hide “Ship to a different address”
        foreach( $user_roles as $user_role ) {
            if ( current_user_can( sanitize_title( $user_role ) ) ) {
                add_filter( 'woocommerce_cart_needs_shipping_address', '__return_false');
                break; // loop stop
            }
        }
    }
    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    I never received a confirmation email as the only support is through woocommerce’s website, I did submit another ticket yesterday and again did not receive a confirmation email.

    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Thank you for your response, I did purchase this and had an issue which I did contact the support team for but never received a reply unfortunately which has put me off this plugin now.

    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Just to let everyone know that my original code was working however something in my theme was blocking it so added the !important string and all working

    /** Hides the add to cart button on the shop/category pages for all visitors
    */
    .add_to_cart_button { 
        display: none !important;
    }
    /** Returns the add to cart button on the shop/category pages for logged in visitors
    */
    .logged-in .add_to_cart_button {
        display: inline-block !important;
    }
    /** Hides the add to cart button on the single product pages for all visitors
    */
    .single_add_to_cart_button {
        display: none !important;
    }
    /** Returns the add to cart button on the single product pages for logged in visitors
    */
    .logged-in .single_add_to_cart_button {
        display: inline-block !important;
    }
    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Thank you for the help, it is much appreciated and actually worked very well, I just had to add a max width to it and all is solved.

    .woocommerce-loop-product__title {
    float: left;
    max-width: 80%;
    }
    .woocommerce-loop-product__title + .price {
    float: right;
    max-width: 20%;
    }

    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Hi,

    Please see the link for an image
    https://ibb.co/yXZ4sYr

    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Thank you for your reply, I have used this widget however its not exactly what I wanted. I am looking to remove the shop sidebar completely from specific categories not the widget within the sidebar.

    Regards
    Chris.

    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Yes, its set up correctly without the www.

    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Thats is what i thought jut wanted to check if there was an automated solution.

    Thanks for the reply.

    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Hi Amanda,

    Thanks for the reply, I have looked into this however i believe you would have to create individual products for this, i am looking to have a button on the product page itself.

    Thanks
    Chris.

    Hi,

    Have you looked into Yith Role Based prices, i have this on one of my sites and it works good for different levels of trade account and its very easy to use.

    This said the pricing is set via percentages which i suppose would make this easy.

    Chris.

    • This reply was modified 6 years, 8 months ago by oakwoodmedia.
    Thread Starter oakwoodmedia

    (@oakwoodmedia)

    Not exactly that, I had a “Request Sample” button placed on specific product pages, this button uses the current product and adds a “sample” product type and removes the cost.

    What i have had to do temporarily is copy all the products and move them into a sample category, i have placed a maximum limit of 5 items from this category and with the code above i have added a sample surcharge of £5 so if a product from [category sample] is in the cart charge £5 surcharge.

    The method i have used is not ideal as i would rather the sample button be placed on each product page i offer a sample for.

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