Title: an29's Replies | WordPress.org

---

# an29

  [  ](https://wordpress.org/support/users/an29/)

 *   [Profile](https://wordpress.org/support/users/an29/)
 *   [Topics Started](https://wordpress.org/support/users/an29/topics/)
 *   [Replies Created](https://wordpress.org/support/users/an29/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/an29/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/an29/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/an29/engagements/)
 *   [Favorites](https://wordpress.org/support/users/an29/favorites/)

 Search replies:

## Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] CSV import skips products](https://wordpress.org/support/topic/csv-import-skips-products/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/csv-import-skips-products/#post-15804358)
 * Hey
    Yes, I am using the built-in CSV importer. Could it be that I have over 
   10 000 products in the CSV? Looks like when i only try 3 it works fine. But when
   i try to use it for all the products, it skips like 9 000 products.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Add a custom fee from an attribute](https://wordpress.org/support/topic/add-a-custom-fee-from-an-attribute/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/add-a-custom-fee-from-an-attribute/#post-15784817)
 * Little update;
 * I think my problem lays here
 *     ```
       // Get weight & attribute values
       $product_weight = $cart_item['data']->get_weight();
       $ah_values = get_the_terms( $product->id, 'pa_ah');
       ```
   
 * If i duplicate the `$cart_item['data']`, I get the white screen of death somehow..
   Is there maybe another line of code that gets the values from the AH attribute?
 * I guess the `$cart_item['data']` gathers all the info from the products in the
   cart. And it only picks out the weight.. Is it possible to use a function to 
   get both the attribute value and the weight and assign them to `$product_weight`
   and `$ah_values`
    -  This reply was modified 3 years, 10 months ago by [an29](https://wordpress.org/support/users/an29/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Add a custom fee from an attribute](https://wordpress.org/support/topic/add-a-custom-fee-from-an-attribute/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/add-a-custom-fee-from-an-attribute/#post-15784326)
 * Thanks!
 * Could you see if you see anything wrong with this code?
 *     ```
       function shipping_weight_and_lead_fee( $cart ) {
       			if ( is_admin() && ! defined( 'DOING_AJAX' ) )
       				return;
   
       			/* SETTINGS */
   
       			// Specific categories
       			$specific_categories = array('Startbatterier', 'Buffalo Bull SHD', 'Li-ion MC batterier', 'NG – Gel Batterier', 'NH - Høyrate Batterier', 'NF – Frontmonterte Batterier', 'NM - 10års Batterier','NS - 5års Batterier', 'Running Bull', 'Power Bull PRO', 'Buffalo Bull', 'Starting Bull', 'Buffalo Bull SHD Pro', 'Power Bull', 'Bike Bull Classic 6V', 'Bike Bull Classic 12V', 'Bike Bull AGM 12V', 'Bike Bull GEL 12V', 'Bike Bull AGM PRO 12V', 'Freshpack', 'AGM', 'GEL');
   
       			// Initial fee
       			$fee = 0.60;
       			$feeah = 2.00;
   
       			/* END SETTINGS */
   
       			// Set variable
       			$total_weight = 0;
       			$total_ah = 0;
   
       			// Loop though each cart item
       			foreach ( $cart->get_cart() as $cart_item ) {
       				// Get product id
       				$product_id = $cart_item['product_id'];
   
       				// Get weight
       				$product_weight = $cart_item['data']->get_weight();
       				$ah_values = get_the_terms( $product->id, 'ah');
   
       				// NOT empty & has certain category     
       				if ( ! empty( $product_weight ) && has_term( $specific_categories, 'product_cat', $product_id ) ) {
       					// Quantity
       					$product_quantity = $cart_item['quantity'];
   
       					// Add to total
       					$total_weight += $product_weight * $product_quantity;
       				}
       				if ( ! empty( $ah_values ) && has_term( $specific_categories, 'product_cat', $product_id ) ) {
       					// Quantity
       					$product_quantity = $cart_item['quantity'];
       					$total_ah += $ah_values * $product_quantity;
       				}
       			}
   
       			if ( $total_weight > 0 ) {          
       				$cart->add_fee( __( 'Miljøtillegg' ), $fee * $total_weight, false );  
       				$cart->add_fee( __( 'Blytillegg' ), $feeah * $total_ah, false ); 
       			}
   
       		}
       		add_action( 'woocommerce_cart_calculate_fees', 'shipping_weight_and_lead_fee', 10, 1 );
       ```
   
 * Im not that advanced yet. So i appreciate all the help i can get.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Add a custom fee from an attribute](https://wordpress.org/support/topic/add-a-custom-fee-from-an-attribute/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/add-a-custom-fee-from-an-attribute/#post-15780368)
 * This is for simple products. It don’t have product variations.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Add a custom fee from an attribute](https://wordpress.org/support/topic/add-a-custom-fee-from-an-attribute/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/add-a-custom-fee-from-an-attribute/#post-15780300)
 * Yes the ah value is set up in the attribute. I’d want to make a similar code 
   to the one i’ve already created. Only this get the ah value. I don’t know how
   to get the ah value. I used this $product_weight = $cart_item[‘data’]->get_weight();
   to get the weight. Is there a simular way to get a value from the attribute?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Additional fee by weight](https://wordpress.org/support/topic/additional-fee-by-weight/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/additional-fee-by-weight/#post-15763098)
 * Thanks for the help! It works.
 * Made my day
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Remap categories with a CSV file](https://wordpress.org/support/topic/remap-categories-with-a-csv-file/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/remap-categories-with-a-csv-file/#post-14190153)
 * I’m aware of this plugin. However my problem is that i want to move categories
   to a new location. I cannot create new ones, because these categories have many
   different products in them, and it would take multiple days to give all a new
   category
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Pay with Vipps and MobilePay for WooCommerce] Sliter med å få gjennom betaling](https://wordpress.org/support/topic/sliter-med-a-fa-gjennom-betaling/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/sliter-med-a-fa-gjennom-betaling/#post-14166312)
 * feilen skjer i Vipps-appen der man godkjenner betalingen. Jeg får meldingen: “
   Betaling feilet.”. Se
    [https://drive.google.com/file/d/1YkfL8FGanAPclAsuKifJMsTBiIj4HKDJ/view?usp=sharing](https://drive.google.com/file/d/1YkfL8FGanAPclAsuKifJMsTBiIj4HKDJ/view?usp=sharing)
   [https://drive.google.com/file/d/16RkFg9FfEmOqq56RNz3VMHEsSZC_dNZd/view?usp=sharing](https://drive.google.com/file/d/16RkFg9FfEmOqq56RNz3VMHEsSZC_dNZd/view?usp=sharing)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Pay with Vipps and MobilePay for WooCommerce] Sliter med å få gjennom betaling](https://wordpress.org/support/topic/sliter-med-a-fa-gjennom-betaling/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/sliter-med-a-fa-gjennom-betaling/#post-14165571)
 * Hei igjen,
 * Har prøvd å slå av og på plugins osv.. Hadde en backup til da det virket som 
   jeg gikk tilbake til. Men det fungerer fortsatt ikke.
 * Så raskt gjennom loggen, fant ingenting som var interessant.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Change product menu](https://wordpress.org/support/topic/change-product-menu/)
 *  Thread Starter [an29](https://wordpress.org/support/users/an29/)
 * (@an29)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/change-product-menu/#post-13639248)
 * Thank you for the answer and links! It works perfectly.

Viewing 10 replies - 1 through 10 (of 10 total)