Combining multiple numeric meta_key’s in an order_by query for a custom woocommerce sorting option [closed]

I would like to create a custom woocommerce product orderby sort option that combines the values of one custom numeric field

  • ‘sort_price’

with another numeric field (woocommerce regular price)

  • ‘_price’

And order the combined values in ASC order

edit: I see this forum is wordpress only, I will take this to the woocommerce plugin forum, apologies, I can’t seem to delete this.

My code so far achieves ordering by sort_price alone but I am unsure how to combine the two.

add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );  function custom_woocommerce_get_catalog_ordering_args( $  args ) {   $  orderby_value = isset( $  _GET['orderby'] ) ? wc_clean( $  _GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );     if ( 'random_list' == $  orderby_value ) {         $  args['orderby'] = 'meta_value_num';         $  args['order'] = 'ASC';         $  args['meta_key'] = 'sort_price';     }     return $  args; } add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby' ); add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' ); function custom_woocommerce_catalog_orderby( $  sortby ) {     $  sortby['random_list'] = 'Price Low to High Custom';     return $  sortby; } 

there is an example in the wp codex which demonstrates using multiple meta keys but I am a little unsure of what the compare and value parts in the array are doing.

    'meta_query' => array(         'relation' => 'AND',         'state_clause' => array(             'key' => 'state',             'value' => 'Wisconsin',         ),         'city_clause' => array(             'key' => 'city',             'compare' => 'EXISTS',         ),      ),     'orderby' => array(          'city_clause' => 'ASC',         'state_clause' => 'DESC',     ), 

An option to reset content

Hi! GSA SER is a wonderful tool. @Sven  &  @s4nt0s You guys are doing great with it already. This is something I came across recently.

I’m using SEO content Machine at the moment and when I want to duplicate campaigns and import/ autofill new content it always merge with old data. I was wondering, if GSA SER has an option to clear all the content like in articles it might come in handy. What I meant by content fields such as comments, bio, forum subjects, website titles and all.

I think it can be useful to save some time and add more value to the GSA SER.

Disable or remove custom option plugin through functions.php

How can I disable or remove a custom plugin’s option through functions.php?

The plugin’s option looks like this:

$  customoption = lisfinity_get_option('membership-phone'); 

I can call this with echo in every page and appears, but I want to remove this option through functions.php with a Woocommerce condition. How can I do that? I attached my bad code for example. My code works and display echo, but can’t disable option. This is my woocommerce conditional code:

        function has_bought_items() {                    $  bought = false;       $  prod_arr = array( '2881', '2887' );       $  customer_orders = get_posts( array(         'numberposts' => -1,         'meta_key'    => '_customer_user',         'meta_value'  => get_current_user_id(),         'post_type'   => 'shop_order',          'post_status' => 'wc-completed'     ) );     foreach ( $  customer_orders as $  customer_order ) {             $  order_id = method_exists( $  order, 'get_id' ) ? $  order->get_id() : $  order->id;         $  order = wc_get_order( $  customer_order );                  foreach ($  order->get_items() as $  item) {                         if ( version_compare( WC_VERSION, '3.0', '<' ) )                  $  product_id = $  item['product_id'];             else                 $  product_id = $  item->get_product_id();                           if ( in_array( $  product_id, $  prod_arr ) )                  $  bought = true;         }     }               return $  bought;         }              if ( has_bought_items() ) {   $  customoption = lisfinity_get_option('membership-phone'); delete_option($  customoption');    }   else {     echo 'dasd';  }       }   add_action( 'wp_head', 'my_custom_function' );    

Get_option use inside switch select option

I try to make inside theme custom admin panel a switch select option. but i cannot get the value of switch case. following is my code:

$  bannerchange = $  _POST['bannerchange'];  if( get_option('bannerchange') != get_option($  bannerchange)) {             $  bannerchange = update_option( 'bannerchange', get_option($  bannerchange));  }  <?php if(isset($  _POST['wphw_submit']) && $  chk):?>   <div id="message" class="updated below-h2">     <p>Content updated successfully</p>   </div>     <?php endif;?>       <form method="post" action="">  <select name="wphw_submit" onchange="this.form.submit()">      <option value="page1"<?php if ($  bannerchange == "page1") { echo " selected"; } ?>>Custom Departure</option>      <option value="page2"<?php if ($  bannerchange  == "page2") { echo " selected"; } ?>>Fixed Departure</option> </select> <noscript><input type="submit" value="Submit"></noscript>  </div> <input type="submit" name="wphw_submit" value="Save changes" class="button-primary" /> <?php  switch ($  bannerchange) {     case 'page2': ?>                  <p>two</p>          <?php         break;     case 'page1':         ?>         <p>one</p>         <?php         break;     }     ?> 

$ bannerchange get always undefined.

Is woo commerce the only option for product add ons and deposits?

I am getting ready to add a shop to my website. It will sell campers. I want people to be able to select the base model (sz) and then add optional items like tool boxes, hitch sz, etc. At "checkout" instead of collecting the full price, we just want to collect 10% of the total due. I think this can be done with Woocommerce. Is there a better way to do this? Any suggestions appreciated! Thanks!!!

Select arbitrary single value for GROUP BY: What’s the fastest option?

I have a query that I use to indicate locations in a map where there are overlapping points:

select     min(objectid) as min_objectid,     longitudex,     latitudey,     count(1) as count,     min(shape) as min_shape from     workorders group by     longitudex,     latitudey having     count(1) > 1 

In the mapping software that I use, I need to include columns like objectid and shape. For those columns, it doesn’t matter which of the grouped-by rows the values come from, just as long as there is a value.

Presently, I’m using min() to get an arbitrary value for those columns. However, I don’t know if that’s the fastest option since finding the minimum value would require calculation — and I wonder if that time spent is unnecessary.

What is the fastest option for getting an arbitrary/single value for GROUP BY in an Oracle query?

How does the Flames of Phlegethos racial feat interact with the sorcerer’s Metamagic option Empowered Spell?

If I have both the Flames of Phlegethos feat and the sorcerer’s Metamagic option Empowered Spell, can I re-roll the same die twice?

The description of the second benefit of the Flames of Phlegethos tiefling racial feat says (XGtE, p. 74):

When you roll fire damage for a spell you cast, you can reroll any roll of 1 on the fire damage dice, but you must use the new roll, even if it is another 1.

The description of the sorcerer’s Metamagic option Empowered Spell reads (PHB, p. 102):

When you roll damage for a spell, you can spend 1 sorcery point to reroll a number of the damage dice up to your Charisma modifier (minimum of one). You must use the new rolls.

You can use Empowered Spell even if you have already used a different Metamagic option during the casting of the spell.

Can you re-roll the same die with both features, or only once? That is, if you re-roll a die with one of these abilities, does the other ability let you re-roll it?

The "You must use the new roll" makes it sound like you cannot, but in general abilities can can override how other abilities work. Is the "keeping the new roll" restriction limited to re-rolls from that ability, or does it apply to all re-rolls from any source?

There is another interpretation of "You must use the new roll." There is a feat called Savage Attacker which reads:

Once per turn when you roll damage for a melee weapon attack, you can reroll the weapon’s damage dice and use either total.

If you compare this to the language in the previous two abilities, you see that the "re-roll and must use the new roll" could be viewed as the alternate to "re-roll and use either roll", and therefore imposes no restriction on other features re-rolling the die.

Settings API: Setting default option via ‘get_option’ fails

  1. All my options are stored in one array test_hs_options
  2. I have select list settings field ( test_hs_options['duration_months'] ) which stores the selected month (1-12).
  3. For this settings field, I would like to set a default option at 5.
  4. All my attempts at setting the default have failed.
  5. What am I missing?
// Callback for displaying sfield_select_duration. function cb_test_hs_sfield_select_duration() {      // get option test_hs_options['duration_months'] value from db.     // Set to '5' as default if option does not exist.     $  options  = get_option( 'test_hs_options', [ 'duration_months' => '5' ] );      $  duration = $  options['duration_months']; // fails!      var_dump($  options); // PHP Notice:  Undefined index: duration_months      // define the select option values for 'duration' select field.     $  months = array( '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12' );      // Display select control     echo '<select id="duration" name="test_hs_options[duration_months]">';         // loop through option values         foreach ( $  months as $  month ) {             // if saved option matches the option value, select it.             echo '<option value="' . $  month . '" ' . selected( $  duration, $  month, false ) . '>' . esc_html( $  month ) . '</option>';         }     echo '</select>'; }