add sub subpage endpoint to woocommerce plugin my-account section

You can’t add alumni-portal/alumni-index as a separate endpoint, because this clashes with the alumni-portal endpoint. This is because rewrite endpoints will capture anything after / as their value. So alumni-portal/alumni-index is the same as alumni-portal, but the alumni-portal query var is set to alumni-index. So rather than registering both endpoints, register alumni-portal a single endpoint, … Read more

How to make a custom button that redirects to a “user specified link while entering product details” woocommerce

You’re getting Call to undefined function get_field() because you don’t have Advanced Custom Fields installed. You’ll need to install ACF, set up a field group, set the location to “Post type is equal to product”, and add a text/link field called “url_demo” in order for it to work. Then your code will go and grab … Read more

Hide price and add to cart button on product page only

This will remove price and add to cart button on the product page Only // Remove Price from the product page remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 ); // Remove Add to cart form from the product page remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );

Allow only 1 quantity of particular product in cart WooCommerce

Try with this add_filter( ‘woocommerce_add_to_cart_validation’, ‘allowed_products_variation_in_the_cart’, 10, 5 ); function allowed_products_variation_in_the_cart( $passed, $product_id, $quantity, $variation_id, $variations) { $product_a = 14576; $product_b = 14091; foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { $cart_product_id = $cart_item[‘product_id’]; if ($cart_item[‘variation_id’]) { $cart_product_id = $cart_item[‘variation_id’]; } if ( ($cart_product_id == $product_a && $variation_id == $product_b) || ($cart_product_id == $product_b && $variation_id … Read more

How to translate text in function.php with WPML [closed]

It should suffice to add a __() around your translatable text: add_action( ‘woocommerce_cart_calculate_fees’, ‘custom_handling_fee’, 10, 1 ); function custom_handling_fee ( $cart ) { if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) return; if ( ‘cod’ === WC()->session->get(‘chosen_payment_method’) ) { $fee = 10; $cart->add_fee( __(‘Cash On Delivery’), $fee, true ); } } You can then … Read more