Forum Replies Created

Viewing 1 replies (of 1 total)
  • I was having the same issue, however I was able to come up with a work around that works for us, it may not work for everyone, but it serves our purpose. We offer free merch coupons to some of our customers and use Printify as the drop shipper, we want these free merch coupons to come with free shipping. If you are using Woocommerce and Printify and are trying to apply a free shipping coupon, then this edit should work for you.

    In the plugins/printify-for-woocommerce/includes/printify-shipping-method.php file, starting at line 216 change the “calculate_shipping()” method to:

    public function calculate_shipping($package = [])
        {
    		//Custom Added Code
    		$free_shipping = false;
    		$coupons = WC()->cart->get_coupons();
    		foreach ( $coupons as $coupon ) {
    			if ( $coupon->get_free_shipping() ) {
    				$free_shipping = true;
    				break;
    			}
    		}
    		//If free shipping is available, make that the only option
    		if (isset($package['managed_by_printify']) && $package['managed_by_printify'] === true && /*Set this to check for free shipping coupon */ $free_shipping) {
                $this->add_rate([
                    'id' => $this->id . '_s',   //Still send the "standard shipping" method to printify, BUT!
                    'label' => 'Free Shipping', //Call it Free Shipping, AND!
                    'cost' => 0,                //Charge nothing for it
                    'calc_tax' => 'per_order',
                ]);
            }
    		else
    		{
    			//Original (without the else statement)
    			if (isset($package['managed_by_printify']) && $package['managed_by_printify'] === true) {
    				$this->add_rate([
    					'id' => $this->id . '_s',
    					'label' => 'Standard',
    					'cost' => $package['printify_shipping_rates']['standard']['cost'] / 100,
    					'calc_tax' => 'per_order',
    				]);
    			}
    
    			if (isset($package['managed_by_printify']) && $package['managed_by_printify'] === true && isset($package['printify_shipping_rates']['express'])) {
    				$this->add_rate([
    					'id' => $this->id . '_e',
    					'label' => 'Express',
    					'cost' => $package['printify_shipping_rates']['express']['cost'] / 100,
    					'calc_tax' => 'per_order',
    				]);
    			}
    		}
        }

    I hope that helps anyone else who is trying to do this.

    Please note that if you do decide to take this route and Printify updates this file at any point, you will lose your code.

    • This reply was modified 3 years, 4 months ago by kstorell.
Viewing 1 replies (of 1 total)