Code to Update Prices and add them for Woocommerce Custom Product Variations Loop

I am actually struggling with some custom functions. Actually My aim is the following: Create 2 custom fields in a woocommerce variable product backend ✔ Show these custom fields text and prices in frontend Make able to add the product in the cart with these prices summed up.

I don’t know which hook I am using wrong and why the theme ajax doesn’t work. There is someone that can assist?

"Working" (I hope) Code

// Aggiunte campi asseverazione, legalizzazione Variazioni nel backend add_action( 'woocommerce_variation_options_pricing', 'add_variation_options_pricing_assev', 10, 3 ); function add_variation_options_pricing_assev( $  loop, $  variation_data, $  variation ){      woocommerce_wp_text_input( array(         'id' => '_assev_'.$  loop,         'wrapper_class' => 'form-row form-row-first',         'class' => 'short wc_input_price',         'label' => __( 'Asseverazione', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',         'value' => wc_format_localized_price( get_post_meta( $  variation->ID, '_assev', true ) ),         'data_type' => 'price',     ) );     woocommerce_wp_text_input( array(         'id' => '_legal_'.$  loop,         'wrapper_class' => 'form-row form-row-last',         'class' => 'short wc_input_price',         'label' => __( 'Legalizzazione', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',         'value' => wc_format_localized_price( get_post_meta( $  variation->ID, '_legal', true ) ),         'data_type' => 'price',     ) );      }  // Salvataggio in backend add_action( 'woocommerce_save_product_variation','save_variation_options_pricing_assev', 10, 2 ); function save_variation_options_pricing_assev( $  variation_id, $  loop ){     if( isset($  _POST['_assev_'.$  loop]))         update_post_meta( $  variation_id, '_assev', wc_clean( wp_unslash( str_replace( ',', '.', $  _POST['_assev_'.$  loop] ) ) ) );     if( isset($  _POST['_legal_'.$  loop]))         update_post_meta( $  variation_id, '_legal', wc_clean( wp_unslash( str_replace( ',', '.', $  _POST['_legal_'.$  loop] ) ) ) ); }  // Frontend (mi manca di aggiungere la legalizzazione) add_filter( 'woocommerce_available_variation', 'display_variation_assev', 10, 3 );  function display_variation_assev( $  data, $  product, $  variation ) {      if( $  assev = $  variation->get_meta('_assev') ) {         $  data['price_html'] = '<div class="woocommerce_assev">' . __( 'Asseverazione: ', 'woocommerce' ) .         '<span class="asseverazione-prezzo">' . wc_price( $  assev ) . '</span></div>' . $  data['price_html'];     }      return $  data; } 

Code Struggle:

/*add_filter( 'woocommerce_add_cart_item', 'aggiorna_prezzi_nuova', 10, 2 ); function aggiorna_prezzi_nuova( $  cart_item_data, $  cart_item_key, $  variation) {                if( isset( $  _POST['_assev_'][$  variation_id] ) )         $  cart_item_data['_assev'][$  variation_id] = $  _POST['_assev'][$  variation_id];     if(isset( $  _POST['_legal'] ) )        $  cart_item_data['_legal'] = $  _POST['_legal'];      return $  cart_item_data; }   add_action( 'woocommerce_before_calculate_totals', 'fissa_valore_var_carrello', 20, 1 ); function fissa_valore_var_carrello( $  cart ) {     if ( is_admin() && ! defined( 'DOING_AJAX' ) )         return;      if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )         return;      // First loop to check if product 11 is in cart     foreach ( $  cart->get_cart() as $  cart_item ){         if( isset($  cart_item['_assev']) && isset($  cart_item['_legal'])          && ! empty($  cart_item['_assev']) && ! empty($  cart_item['_legal']) )             $  cart_item['data']->set_price( '30' );     } }*/ 

Other non functional code:

function aggiorna_prezzo( $  price, $  product ) {         $  shortcost_first = get_post_meta( $  variation->id, '_assev_0', true );    $  shortcost_mid = get_post_meta( $  product->id, '_assev_0', true );   $  shortcost_minimum = get_post_meta( $  product->id, 'assev_0', true );        $  unit_price = $  assev + $  shortcost_mid + $  shortcost_first + $  shortcost_minimum; //     +($  shortcost_mid * ($  shortcost_minimum - 1));    return $  price + $  unit_price;       } add_filter('woocommerce_get_price', 'aggiorna_prezzo', 10, 3); add_filter('woocommerce_get_regular_price','aggiorna_prezzo', 10, 3); add_filter('woocommerce_get_sale_price','aggiorna_prezzo', 10, 3); 

Thank you!

Creatin Products Database with Multiple Color Variations

I found this Q&A already, that describes my problem and a more or less satisfying answer: Create products with color variants Basically, I want to set up a database for products with different color variations. Here the solution is given of setting up a product-table, a color-table, and a product-color-table as a combination of both.

Unfortunately, most of my products are available in ~180 different colors and we have about 8000 different articles. Additionally, every product has at least one standard color (up to ~5 standard colors) out of the 180 colors in which the product is cheaper than in other colors.

Do I really have to set up a database as described before, which would lead to over 1 Mil articles, or is there another way? I thought of setting up a product-color-table in the sense, that there are 180 columns for each color and I just assign them values like “available, not-available, standard” or so. And then all the other information that don’t really affect the price of the products in yet another table.

But since I’m new to setting up databases I don’t really how I can realise it. Would that actually work? Can anyone give me any tips on how I can solve that and set up my tables?

Thanks in advance

PS: In case my description was confusing here is an example of an onlineshop I found that has the exact thing I want to do: When you tap on “Ciew colour range” you can see all the different colors. But then there are also other articles that are available in less colors or different standard-colors.

Woocommerce – problem with number of variations

I have a product with 300+ variations. I’m currently using the Bulk Variation Forms plugin to display the information in the page with a couple of visual customizations.

The problem is that the ADD TO CART functionality doesn’t work at all, but if i choose a product that has a less number of variations, it works normal.

I’ve alredy changed my max_input_vars in my php.ini.

How do i increment the number of variations? Is this the cause of my ADD TO CART functionality not working?

Wild shape Variations Stacking

Can a druid take a wild shape form then shape into another for an keep the abilities from the first form? For example A moon Druid shapes into a Fiendish Giant Spider. resistance to cold. fire, and lightning damage, and immunity to poison damage. They are also immune to the poisoned condition. Then from that form shifts to a cranium rat.

Using up the 2nd shift. Could you make a hybrid form? Much like later when as a moon druid you can make an Elemental form with 2 uses of wild shape.

Issue with Variations on SharePoint 2019

I have a site with 12 pages inside the /Pages document library and also 5 sub-sites and 7 lists.

I want to create variations for this site in English and French (French package language already installed).

But the issue is, after I create the labels, and then click on Create Hierarchy. This is the error occurring:

The Variations Create Hierarchies job failed with the following error message:

Object reference not set to an instance of an object.

The variations are created but the pages, lists and sites are not propagated. Also, there is no routing managed even if the Variation Root page exists.

I deleted the labels and the variations sites, and then re-do the operation but the error is still occurring.

Please help.

Variations of the halting problem

Let $ M$ be an arbitrary Turing machine and $ w \in \{0, 1\}^{*}$ be a binary string.

The language $ \text{HALT} = \{\langle M, w \rangle : M ~\text{halts on input} ~w \}$ is undecidable by the famous diagonalization proof.

But what happens when we either fix the Turing machine $ M$ or the input $ w$ ?

Formally, for a fixed $ M_{0}$ in the first case and a fixed $ w_{0}$ in the second case, are these two languages still undecidable? Is there any dependence on the nature of $ M_{0}$ or $ w_{0}$ ?

  • $ \text{HALT}_{M_{0}} = \{w : M_{0} ~\text{halts on input} ~w \}$

  • $ \text{HALT}_{w_{0}} = \{\langle M \rangle : M ~\text{halts on input $ w_{0}$ } \}$

For the first language, I found a proof online (Proposition 17.2), but it seems specific to the nature of $ M_{0}$ which is probably intuitive. I am more intrigued by the second case.

Stock Reduction Multiplier For Variations

I have a customer who is looking at moving to Magento, but one of her major barriers is that we have a custom code programmed for Woocommerce to allow stock to be sold in individual quantities and box quantities using variations.

So for example, she sells a blue glass bottle. You can select a variation of either:

  • Individual items (and multiple using the QTY)
  • Box Quantity (and multiple using the QTY)

When a customer purchases a box variation (of 32 items) the stock will reduce the product inventory by 32.

The reason it is done this way is that she doesnt hold the stock in pre-packaged boxes. Instead if she orders a box quantity she will package them up into a bundle of 32 for shipping. So the stock between individual and box variations are from the same pool.

Does anyone have any idea how this can be achieved in Magento? In wordpress we have a box when adding a variation which is pretty much “Reduce QTY by [ ]” where you can enter “32” so if a box is purchased it reduces stock by 32.

Any help would be greatly appreciated.

Variations on Kaplansky Density

Let $ A$ be a $ C^*$ -algebra and $ \pi:A\rightarrow B(H)$ a faithful $ *$ -representation, so $ M=\pi(A)”$ is a von Neumann algebra and $ A\rightarrow M$ is an inclusion. von Neumann’s Bicommutant Theorem tells us that $ A=\pi(A)$ is weak$ ^*$ -dense in $ M$ , and the Kaplansky Density Theorem says that further, the unit ball of $ A$ is weak$ ^*$ -dense in that of $ M$ .

Suppose now I have $ a\in A$ and $ k\geq 0$ fixed, and there is $ x\in M$ with $ $ \|a-x\|\leq k, \quad \|x\|\leq 1. $ $

Is $ x$ is the weak$ ^*$ -closure of the set $ \{ b\in A : \|a-b\|\leq k, \|b\|\leq 1 \}$ ?

If $ a=0$ this is just Kaplansky density.

Let’s weaken this, and just ask: is there $ b\in A$ with $ \|a-b\|\leq k$ and $ \|b\|\leq 1$ ? This follows from just the triangle-inequality, because it is easy to see that $ $ \inf\{k\geq 0 : \exists b, \|a-b\|\leq k, \|b\|\leq 1\} = \max(0, \|a\|-1). $ $ So if $ \|a-x\|\leq k$ and $ \|x\|\leq 1$ then $ \|a\|\leq k+1$ and so $ \|a\|-1\leq k$ .

So, let’s make this new problem harder. Let $ a_0\in A^+$ (so $ a_0$ is positive: this is motivated by other considerations) and ask the following:

Suppose there is $ x\in M$ with $ \|a-a_0x\|\leq k$ and $ \|x\|\leq 1$ . Is there $ b\in A$ with $ \|a-a_0b\|\leq k$ and $ \|b\|\leq 1$ ?

One could also consider more general maps $ T:A\rightarrow A$ which extend to $ M\rightarrow M$ ; here $ T(b) = a_0b$ .