Forum Replies Created

Viewing 13 replies - 91 through 103 (of 103 total)
  • Forum: Hacks
    In reply to: Handling Fee Plugin

    Here’s the code. I just want the input field to store data on both sides of the decimal point, and then pass it to the corresponding field in the Checkout.

    Thanks!

    add_action( 'add_meta_boxes', 'wdh_add_handling_metaboxes' );
    function wdh_add_handling_metaboxes()
            {
    			add_meta_box('wdh_handling_meta_side', 'Handling', 'wdh_handling_fee', 'product', 'side', 'default');
    		}
    
    function wdh_handling_fee()
            {
    			global $post, $woocommerce ;
    			echo '<table class="form-table">';
    			// Noncename needed to verify where the data originated
    			echo '<input type="hidden" name="wdc_handling_fee_noncename" id="wdc_handling_fee_noncename" value="' .
    			wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
    			echo '<tr>';
    			echo '<th style="width:40%"><label for="lead_name"><strong>Handling fee:</strong></label></th>';
    			// Get the location data if its already been entered
    			$wdc_handling_fee = get_post_meta($post->ID, 'wdc_handling_fee', true);
    			// Echo out the field
    			echo '<td><input type="text" name="wdc_handling_fee" value="' . $wdc_handling_fee  . '"  size="30" style="width:60%" /></td>';
    			echo '</tr>';
    
    			echo "</table>";	
    
    		}
    
    // Save the Metabox Data
    function wdh_save_handling_meta($post_id, $post)
            {
    
    			// verify this came from the our screen and with proper authorization,
    			// because save_post can be triggered at other times
    			if ( !wp_verify_nonce( $_POST['wdc_handling_fee_noncename'], plugin_basename(__FILE__) )) {
    			return $post->ID;
    			}
    
    			// Is the user allowed to edit the post or page?
    			if ( !current_user_can( 'edit_post', $post->ID ))
    				return $post->ID;
    
    			// OK, we're authenticated: we need to find and save the data
    			// We'll put it into an array to make it easier to loop though.
    
    			$lead_meta['wdc_handling_fee'] = $_POST['wdc_handling_fee'];
    
    				// Add values of $lead_meta as custom fields
    
    				foreach ($lead_meta as $key => $value) { // Cycle through the $lead_meta array!
    					if( $post->post_type == 'revision' ) return; // Don't store custom data twice
    					$value = implode(',', (array)$value);
    					if(get_post_meta($post->ID, $key, FALSE)) { // If the custom field already has a value
    						update_post_meta($post->ID, $key, $value);
    					} else { // If the custom field doesn't have a value
    						add_post_meta($post->ID, $key, $value);
    					}
    					if(!$value) delete_post_meta($post->ID, $key); // Delete if blank
    				}
    
    		}
    
    add_action('save_post', 'wdh_save_handling_meta', 1, 2); // save the custom fields
    
    class WC_Settings_Tab_Handling
         {
    
        	 public static function init() {
            add_filter( 'woocommerce_settings_tabs_array', __CLASS__ . '::add_settings_tab', 50 );
        	}
    
    		public static function add_settings_tab( $settings_tabs ) {
    			$settings_tabs['handling'] = __( 'Handling', 'woocommerce-handling' );
    			return $settings_tabs;
    		}
    	}
    
    	WC_Settings_Tab_Handling::init();
    
    add_action( 'woocommerce_settings_tabs_handling', 'wdh_settings_tab_handling' );
    
    function wdh_settings_tab_handling() {
        woocommerce_admin_fields( wdh_get_settings_handling() );
    }
    
    function wdh_get_settings_handling() {
        $settings = array(
            'section_title' => array(
                'name'     => __( 'Handling Settings', 'woocommerce-settings-tab-handling' ),
                'type'     => 'title',
                'desc'     => '',
                'id'       => 'wc_settings_tab_handling_section_title'
            ),
            'title' => array(
                'name' => __( 'Costs Added...', 'woocommerce-handling' ),
                'type' => 'select',
                'desc' => __( '', 'woocommerce-handling' ),
                'id'   => 'wc_settings_tab_handling_type',
    			'options'  => array(
    								'per_item' => __('Per Item - charge handling fee for each item individually', 'woocommerce' ),
    								'per_order' => __('Per Order - charge handling fee for the entire order as whole', 'woocommerce' ),
    								'per_max_item' => __('Per Max Item - Charge handling fee for the entire order as whole(ony max handling will charge)', 'woocommerce' ),
    								)
            ),
    
            'section_end' => array(
                 'type' => 'sectionend',
                 'id' => 'wc_settings_tab__handling_section_end'
            )
        );
        return apply_filters( 'wc_handling_settings', $settings );
    }
    
    add_action( 'woocommerce_update_options_handling', 'wdh_update_settings_handling' );
    
    function wdh_update_settings_handling() {
        woocommerce_update_options( wdh_get_settings_handling() );
    }
    
    /*
    ** Add handling fee to cart
    */
    
    add_action( 'woocommerce_cart_calculate_fees','wdh_charge_handling_fee' );
    function wdh_charge_handling_fee() {
         global $woocommerce;
    
         $handling_type = get_option('wc_settings_tab_handling_type');
    	 foreach($woocommerce->cart->get_cart() as $cart_item_key => $values ) {
    		$_product = $values['data'];
    		$handling[$_product->id] = intval(get_post_meta($_product->id, 'wdc_handling_fee', true));
    
    	 }
    
    	 if($handling_type == 'per_max_item')
    	    {
    		  $fee = max($handling);
    		  if ( is_admin() && ! defined( 'DOING_AJAX' ) )
              return;
    
         	  $woocommerce->cart->add_fee( 'Handling', $fee, true, 'standard' );
    		}
    	 elseif($handling_type == 'per_order')
    	    {
    		  $fee = array_sum($handling);
    		  if ( is_admin() && ! defined( 'DOING_AJAX' ) )
              return;
    
         	  $woocommerce->cart->add_fee( 'Handling', $fee, true, 'standard' );
    		}
    	elseif($handling_type == 'per_item')
    	    {
    			foreach($handling as $key => $item)
    			        {
    						$p_name = get_the_title( $key );
    						$h_title = 'Handling for '.$p_name;
    						$woocommerce->cart->add_fee( $h_title, $item, true, 'standard' );
    
    					}
    		}else{
    			$fee = array_sum($handling);
    		  	if ( is_admin() && ! defined( 'DOING_AJAX' ) )
             	return;
    
         	  	$woocommerce->cart->add_fee( 'Handling', $fee, true, 'standard' );
    		}
    
    }

    Anybody?!

    I’m getting the same error message.

    Forum: Fixing WordPress
    In reply to: Can't Upload Media

    That sounds like it’d prevent me from otherwise being able to upload images at all. This is a ‘new’ thing.

    I’ll ask them about it, but what do I specifically ask them about within the mod_security module? Do I presume GoDaddy has modified their module without testing it to see if it disables core functionality for their WP hosting they sell specifically?

    esmi, I’m not saying you have the authority to implement this, but a useful feature for folks experiencing the same issue would be a checkbox that would add to a tally of people experiencing the same issue. That’d help keep the board free of redundant issues.

    Whoops. That moves the icon down so that it’s in line with the menu, however the hover functionality isn’t going with it. /o:

    ¡Muchas gracias!

    I got it working. Turns out there’s a missing icon in one of the font/icon packs that comes supplied with the theme.

    However, I cannot get it to be ‘in-line’ with the header menu. It’s residing above it. Eh. Good enough for govt work? Sure. But I want to ‘wow’, rather than ‘not bad’, my client.

    dev.robywebdesign.com

    cantonjester

    (@cantonjester)

    They addressed issue this AM. Apparently, I needed to download the plugin via their website, not via the plugin page in the WP admin panel.

    cantonjester

    (@cantonjester)

    After looking at the documentation more closely, I see that one of the tabs in the List/Grid View settings should be ‘License’.

    That’s not appearing.

    I contacted ‘BeRocket’, but has anybody experienced this?

    cantonjester

    (@cantonjester)

    ah…You mean, I should’ve just used the ‘website/server manager’ side of my brain.

    I should’ve just renamed it ‘BooCommerce’.

    Actually, I nuked it, reinstalled it, activated it, and then I set the default customer address to ‘No Address’. Seems to be working now.

    Question: Is there someplace else in the wooCommerce admin to shutoff any ‘listening’ the Geo IP API may be doing?

    I appreciate the help!

    cantonjester

    (@cantonjester)

    I think I’m having the same problem. I can’t access the Woocommerce settings at all though. The entire site front/back is down.

    Is my only recourse to nuke the plugin via FTP at this point, and then reinstall and not use the GEO location of doom?

Viewing 13 replies - 91 through 103 (of 103 total)