• Resolved Eugene.chint

    (@eugenechint)


    I am looking forward for above query. Say a customers places order of two products t shirt by vendor A with flat shipping rate 15% priced at 10$and socks offered by vendor B for 5$ available on Cash on delivery. Freezing payment checkout can be done for specific category and products but output which i desire is Cart total shows 15$ but only for A with options to pay for 10$ other than COD and B is mentioned as COD. (So customer pays only 10$ and rest is mentioned as COD) i tried this but it hides complete payment gateway. Also shipping rates are not calculated on cart totals

    
    
      function filter_gateways($gateways){
    
      $payment_NAME = 'dibs'; // <--------------- change this
      $category_ID = '15';  // <----------- and this
    
       global $woocommerce;
    
       foreach ($woocommerce->cart->cart_contents as $key => $values ) {
          // Get the terms, i.e. category list using the ID of the product
          $terms = get_the_terms( $values['product_id'], 'product_cat' );
          // Because a product can have multiple categories, we need to iterate through the list of the products category for a match
          foreach ($terms as $term) {
              // 20 is the ID of the category for which we want to remove the payment gateway
              if($term->term_id == $category_ID){
                     unset($gateways[$payment_NAME]);
                         // If you want to remove another payment gateway, add it here i.e. unset($gateways['cod']);
                          break;
                }
              break;
          }
    
         }
          return $gateways;
    
      }
    
      add_filter('woocommerce_available_payment_gateways','filter_gateways');
Viewing 3 replies - 1 through 3 (of 3 total)
  • Luminus Alabi a11n

    (@luminus)

    Automattic Happiness Engineer

    @eugenechint,

    It looks like what you’re trying to do here is split the products in that order into separate packages so that you can apply different shipping methods to them.

    The WooCommerce Advanced Shipping Packages extension will help make the split possible.

    You can then use the Conditional Shipping & Payments extension to disable/enable shipping methods based on your requirements.

    Thread Starter Eugene.chint

    (@eugenechint)

    great plugin features saw on wooc website but i am looking to have products excluded from payment gateway page mentioning under cod along with other.i can see category but not product

    Luminus Alabi a11n

    (@luminus)

    Automattic Happiness Engineer

    @eugenechint,

    The Conditional Shipping & Payments extension lets you work based on categories or shipping classes. You’ll need to add all the products for which you want to exclude a payment gateway to the same category or shipping class and then use the extension to exclude them.

    It is a saner way to approach things than having to edit the setting everytime you add a new product. All you’d need to do for new products is to add them to the appropriate category or shipping class and they will be treated like all the rest.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Woocommerce COD for specific product’ is closed to new replies.