Get WooCommerce shipping methods programmatically

How can I retrieve the shipping methods in my WooCommerce shop? I have this on my checkout page:

my checkout page

And inside my admin it looks like this:

shipping methods in wp admin

I have tried doing:

WC()->shipping->load_shipping_methods() 

But it does not return GLS or Click and collect text / price. It returns this data: https://paste.laravel.io/0c1aff96-dbed-452c-856f-6d62b6f1f47e

Change Template view of proucts on click button with javascript woocommerce

I use woocommmerce and i have two template view for products (content-product.php) and (contentcarousel-product.php) . in (archive-product.php) per defaut display first template like this

<?php wc_get_template_part( 'content', 'product' ); ?> 

I created two button like this with onclick event with javascript

<button onclick="Viewone()"> view 1</button> <button onclick="Viewtwo()"> view 2</button> 

I want when click button 1 display first template per defaut and when click button 2 display second template.

How i can do this with javascript and php

Creating a Woocommerce custom shipping method as a select field

I’m working with thw WooCommerce plugin for WordPress. My main goal right now is to create a custom shipping method. So far I’ve managed to create this method and display the same in my billing form. The problem is that this shipping methods are checkbox by default and I want an extra funcionality: Display a select with a series of options as soon a I select this custom shipping method on the billing order form.

This next class handles the custom shipping method:

/**  * WC_Shipping_Pickup class.  *  * @class       WC_Shipping_Pickup  * @version     1.0.0  * @package     Shipping-for-WooCommerce/Classes  * @category    Class  * @author      Pickup Softwares  */ class WC_Shipping_Pickup extends WC_Shipping_Method {     public function __construct($  instance_id = 0)     {         $  this->id                    = 'pickup_method';         $  this->instance_id           = absint($  instance_id);         $  this->method_title          = __('Pickup');         $  this->method_description    = __('Método de envío: punto de pickup');         $  this->supports              = array(             'shipping-zones',             'instance-settings',         );          $  this->instance_form_fields = array(             'enabled' => array(                 'title'         => __('Habilitar/Deshabilitar'),                 'type'          => 'checkbox',                 'label'         => __('Habilitar este método de envío'),                 'default'       => 'yes',             ),             'title' => array(                 'title'         => __('Título'),                 'type'          => 'text',                 'description'   => __('Título que se visualizará en el formulario de facturación'),                 'default'       => __('Pickup'),                 'desc_tip'      => true             )         );          $  this->enabled              = $  this->get_option('enabled');         $  this->title                = $  this->get_option('title');          add_action('woocommerce_update_options_shipping_' . $  this->id, array( $  this, 'process_admin_options' ));     }      public function calculate_shipping($  package = array())     {         $  this->add_rate(array(             'id'    => $  this->id . $  this->instance_id,             'label' => $  this->title,             'cost'  => 0,         ));     }      /**      * Generate Select HTML.      *      * @param string $  key Field key.      * @param array  $  data Field data.      * @since  1.0.0      * @return string      */     public function generate_select_html()     {         $  token = null;         $  expire = null;         $  token = qk_login($  token, $  expire);          $  agencies = qk_agencies($  token);          $  field_key = $  this->get_field_key('_pickups');          $  options = [];         foreach ($  agencies as $  agency) {             $  options[$  agency->id] = $  agency->detalle;         }          $  defaults  = array(             'title'             => 'Pickups',             'disabled'          => false,             'class'             => '',             'css'               => '',             'placeholder'       => 'Seleccionar punto de recogida',             'type'              => 'text',             'desc_tip'          => false,             'description'       => '',             'custom_attributes' => array(),             'options'           => $  options,         );          $  data = wp_parse_args($  data, $  defaults);          ob_start(); ?>         <tr valign="top">             <th scope="row" class="titledesc">                 <label for="<?php echo esc_attr($  field_key); ?>"><?php echo wp_kses_post($  data['title']); ?> <?php echo $  this->get_tooltip_html($  data); // WPCS: XSS ok.?></label>             </th>             <td class="forminp">                 <fieldset>                     <legend class="screen-reader-text"><span><?php echo wp_kses_post($  data['title']); ?></span></legend>                     <select class="select <?php echo esc_attr($  data['class']); ?>" name="<?php echo esc_attr($  field_key); ?>" id="<?php echo esc_attr($  field_key); ?>" style="<?php echo esc_attr($  data['css']); ?>" <?php disabled($  data['disabled'], true); ?> <?php echo $  this->get_custom_attribute_html($  data); // WPCS: XSS ok.?>>                         <?php foreach ((array) $  data['options'] as $  option_key => $  option_value) : ?>                             <option value="<?php echo esc_attr($  option_key); ?>" <?php selected((string) $  option_key, esc_attr($  this->get_option($  key))); ?>><?php echo esc_attr($  option_value); ?></option>                         <?php endforeach; ?>                     </select>                     <?php echo $  this->get_description_html($  data); // WPCS: XSS ok.?>                 </fieldset>             </td>         </tr>         <?php          return ob_get_clean();     } } 

I’ve been trying to use this generate_select_html function to generate this select input but I’m actually running with my eyes closed because I don’t know if this is right way to do things. That piece of code causes an infinite loading page on the billing form so it is wrong (obviusly). Is there a way to adchieve what I want?

YITH Product add on does not show with WooCommerce Multi Currency Premium

I need Help… I sell tickets to the event with different types of add ons in Euro but at the checkout page the prices have to be converted to MDL currency because of the legislation, so the whole way until checkout page the Product addons show correctly in Euro but at the checkout page the amount remains the same and not converted to MDL just the symbol of the currency is changed so the problem is when I add product add-ons to the cart along with the main product the amount on the left side at the checkout does not change however the total price is calculated correctly so it doesn’t look clear to the customers and for my partners at the end and in the invoice( check the screenshots)
I presume I can do it adding some code in function.php, but I do not know what code???
Thank You Very Much and hope very soon to fix it

https://prnt.sc/qrtn4b
https://prnt.sc/qrtnjr
https://prnt.sc/qrtnw3

Save custom price radio button value in cart and display it on Cart page Woocommerce

I have added custom price on woocommerce single product page using the code below on my theme’s functions php:

<?php // Output the Custom field in Product pages add_action("woocommerce_before_add_to_cart_button", "options_on_single_product", 1); function options_on_single_product(){  ?> <ul class="pricing-options"> <li> <div class="custom-radio"> <input type="radio" id="opt1" class="" name="filter_opt" checked> <label for="opt1" data-price="<?php echo wc_price( $  price ) ;?>"> <span class="circle"></span>Single Site License </label> </div>  <p>Nunc placerat mi id nisi interdum is mollis. Praesent pharetra, justo ut sceleris que      the mattis, leo quam.</p> </li>  <li> <div class="custom-radio"> <input type="radio" id="opt2" class="" name="filter_opt"> <label for="opt2" data-price="<?php echo wc_price( $  price*3 ) ;?>"> <span class="circle"></span>2 Sites License</label>  </div>  <p>Nunc placerat mi id nisi interdum is mollis. Praesent pharetra, justo ut sceleris que         the mattis, leo quam.</p> </li> </ul> <?php } 

Now i want to display the selected option value on cart page. Please help me to do this. Thanks

List just subcategory and products of active category page in Woocommerce

Working on a category page – taxonomy-product_cat.php – I want to list all the subcategories of that category page, with all its products. I would think it is simple enough but I cant get it to work.

I can list all categories of the shop with all subcategories and all products – So for example bags would list all products of the whole shop.

Or I can list the subcategories of just the category page – but without the products listed.

How can I list just the subcategories of the category page with their products?

The code I am using that works great, but loops all the categories in the shop, and not just the active category is:

$  args = array('taxonomy' => 'product_cat' ); $  all_categories = get_categories( $  args );  foreach ($  all_categories as $  cat) {     $  category_id = $  cat->term_id;     $  args2 = array('taxonomy' => $  taxonomy,'parent' => $  category_id,'hierarchical' => $  hierarchical, 'orderby' => $  orderby, 'order' => $  order,'hide_empty' => $  empty); $  categories = get_categories( $  args2 );   $  sub_cats = get_categories( $  args2 );             if($  sub_cats) {                 foreach($  sub_cats as $  sub_category) {                     echo "<h2>".$  sub_category->cat_name."</h2>";                      $  args = array( 'post_type' => 'product','product_cat' => $  sub_category->slug, 'orderby' => $  orderby, 'order' => $  order);                             $  loop = new WP_Query( $  args );                                while ( $  loop->have_posts() ) : $  loop->the_post(); global $  product; ?>                               <!--HTML HERE-->                               <?php endwhile;  wp_reset_query();  }}} ?> 

Get x numbers of a woocommerce category products using Wp_Query

Is possible to show some woocommerce products inside a swiper slider? I want to create a slider that will show some “featured” products on the home page. For now I have a cpt that is achieving this, but I don’t know how to link them to the products that I will add to woocommerce. So I want to replace the cpt with a query to get an x number of products from woocommerce products and put them into the slider. Any help will be appreciated.

The code I’m using now is this

<div class="row featured-row" <?php $  featured = new WP_Query( ['post_type' => 'featured', 'order' => 'ASC', 'posts_per_page' => 3] ); ?> <?php $  i = 0; ?> <?php if( $  featured->have_posts() ): while( $  featured->have_posts() ): $  featured->the_post(); ?> <?php #$  class = get_post_meta( get_the_ID(), 'class', true); ?> <?php if( $  i === 1 ): ?>   <div class="col-md-6 col-lg-6 d-none d-sm-none d-md-block featured-desc">     <h2 class="featured-title-right text-right"><?php the_title(); ?></h2>     <p class="featured-excerpt-right text-right"><?php echo get_the_excerpt(); ?></p>   </div>   <div class="col-md-6 col-lg-6 text-center d-none d-sm-none d-md-block featured-img">     <img class="img-fluid" src="<?php the_post_thumbnail_url(); ?>">   </div> <?php else: ?>   <div class="col-md-6 col-lg-6 text-center d-none d-sm-none d-md-block featured-img">     <img class="img-fluid" src="<?php the_post_thumbnail_url(); ?>">   </div>   <div class="col-md-6 col-lg-6 d-none d-sm-none d-md-block featured-desc">     <h2 class="featured-title"><?php the_title(); ?></h2>     <p class="featured-excerpt"><?php echo get_the_excerpt(); ?></p>   </div> <?php endif;?> <?php $  i++; ?> <?php endwhile; ?> <?php endif; wp_reset_postdata(); ?> </div>  

WooCommerce IF statements not working

I am trying to use the WooCommerce Conditional Tags to only include a template into specific product pages. https://docs.woocommerce.com/document/conditional-tags/

However my statements aren’t working, and they show on all pages. I’d like to NOT display my template in a specific category and its product pages:

// Show in Shop Page OR NOT in Products IDs 15852,15859,15863,15866 OR NOT Category Archive Gift Cards

I’ve also tried the opposite:

Can you please advise how to get it to work?

Our website: https://grindersforlife.com/shop

Thanks!