Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Great fix and update to the plugin Varun… As always…

    Thread Starter joe_cowboy

    (@joe_cowboy)

    ok, I will do that…

    Thread Starter joe_cowboy

    (@joe_cowboy)

    It’s set to keep all items. So it’s not doing this with the current woocommerce on your set up?

    Thread Starter joe_cowboy

    (@joe_cowboy)

    If you can test this on your end with your current code and see if you remove the Donation from your cart and add it back in is when it removes all items from your cart.

    Also, if you can test this on your end with your current code and see if you are on the cart page, you add donation and it will remove all items from the cart.

    Thread Starter joe_cowboy

    (@joe_cowboy)

    Change the above statement to:

    add_filter( ‘wc_add_to_cart_message’, array($this,’custom_add_to_cart_message’), 10, 2 );

    However, this does not resolve the issue I stated. I figured out part of it. If you remove the Donation from your cart and add it back in is when it removes all items from your cart.

    It also occurs if you are on the cart page, you add donation and it will remove all items from the cart.

    Thread Starter joe_cowboy

    (@joe_cowboy)

    Adding message that donation has been added is for some reason deleting the other cart items… I know this is not your code but my idea.
    Doing it either way removes cart items:

    wc_add_to_cart_message( $added_to_cart );

    or

    add_filter( ‘wc_add_to_cart_message’, ‘custom_add_to_cart_message’ );

    /**
    	 * Output success messages
    	 **/
    	function custom_add_to_cart_message() {
    		global $woocommerce;
    
    		if ( get_option('woocommerce_cart_redirect_after_add') == 'yes' ) {
    			$return_to = get_permalink(woocommerce_get_page_id('shop'));
    			$message = sprintf('<a href="%s" class="button">%s</a> %s', $return_to, __('Continue Shopping →', 'woocommerce'), __('Thank You! Donation successfully added to your cart.', 'woocommerce') );
    		} else {
    			$message = sprintf('<a href="%s" class="button">%s</a> %s', get_permalink(woocommerce_get_page_id('cart')), __('View Cart →', 'woocommerce'), __('Thank You! Donation successfully added to your cart.', 'woocommerce') );
    		}
    
    		return $message;
    	}
    Thread Starter joe_cowboy

    (@joe_cowboy)

    I can probably figure it out. Never have tried. What are you needing done?

    Thread Starter joe_cowboy

    (@joe_cowboy)

    Thanks for figuring out the issue. It is working with Woocart Pro fine now when you submit donation. Another tweak to woocommerce-quick-donation.php code. I will try and get these modes on github for you later.

    /**
    	 * Adds Donation Product To Cart
    	 */
    	private function add_donation_cart(){
    		global $woocommerce;
    		$was_added_to_cart = false;
    		$this->remove_cart_items();
    
    		// Add to cart validation
    		$passed_validation =  apply_filters( 'woocommerce_add_to_cart_validation', true, $this->donation_id,  $quantity=1 );
    
    		if ( $passed_validation ) {
    			if ($woocommerce-> cart->add_to_cart($this->donation_id, $quantity=1) ) {
    				$was_added_to_cart = true;
    				$added_to_cart[] = $this->donation_id;
    			}
    		}
    
    		if ( $was_added_to_cart ) {
    			wc_add_to_cart_message( $added_to_cart );
    		}else {
    				wc_add_notice( __( 'There was an issue adding Donation to your cart;', 'woocommerce' ), 'error' );
    				return;
    			}
    
    		$this->redirectCART();
    	}
    Thread Starter joe_cowboy

    (@joe_cowboy)

    I have been pouring through your code and trying to figure out if it was an issue with the item when it was created. What did you find out was causing the issue?

    Thread Starter joe_cowboy

    (@joe_cowboy)

    Ok, Went through and removed all the fields from the database and reinstalled the plugin. Woocommerce 2.3.X still giving the same issue of Internal Server Error when shopping cart is empty. If there is an item in the shopping cart it will update the cart and add the donation item.

    Thread Starter joe_cowboy

    (@joe_cowboy)

    I will work on this tomorrow and get back with you with my findings and let you know if removing the fields and reinstalling the plugin will fix the current issue with the latest release of WooCommerce 2.3.X. I will also try to come up with a check for X Theme and post my updates on guthub for you.

    I also came up with a mod for it to create a donation image too when it installs. I can design you an image for your donation when it’s added to the cart. Then people can change at will from within the product item settings. That’s if you want me to?

    Thread Starter joe_cowboy

    (@joe_cowboy)

    Well this “fix” needs some mods to it to determine if X theme is installed so it will not break other peoples sites. I do have an account on git hub and I can do that. But I still need help tracking down issue with the current WooCommerce 2.3.X release I can’t for the life of me figure out why it does not like creating a donation without something in the shopping cart already. I thought about going into the database and manually deleting all the fields created by the plugin because I found out when you go to uninstall it does not remove everything from the WordPress database. And reinstalling the plugin see if that will cure anything. Since woocommerce does update the database with this release.

    Thread Starter joe_cowboy

    (@joe_cowboy)

    P.S.

    I modded your donation_form.php to work with X theme to work with the bottom footer widget. So the above script code works in conjunction with this mod.

    Code as follows:

    <?php
    /**
     * Single Product Image
     *
     * @author 		Varun Sridharan
     * @package 	WC Quick Donation/Templates
     * @version     0.1
     */
    
    if ( ! defined( 'ABSPATH' ) ) 	exit; // Exit if accessed directly
    
    global $donate;
    ?>
    
    <script type="text/javascript" language="javascript">
    	jQuery(document).ready(function ($) {
    		ContentString = '<h4 class="h-widget">Make a Donation</h4><div class="textwidget">Any mount welcome:<br>'+
    		'<form method="post">'+
    		'	<table>'+
    		'		<tr class="donation-block">'+
    		'			<td colspan="6">'+
    		'				<div class="donation">'+
    		'					<p class="message"><strong>Add a donation to your order:</strong></p>'+
    		'					<?php do_action('wc_qd_show_projects_list'); ?>'+
    		'					<div class="input text">'+
    		'						<label>Donation ($):</label>'+
    		'						<input type="text" name="donation_ammount" value="<?php echo $donate; ?>"/>'+
    		'					</div>'+
    		'					<div class="submit_btn">'+
    		'						<input type="submit" name="donation_add" value="Add Donation"/>'+
    		'					</div>'+
    		'				</div>'+
    		'			</td>'+
    		'		</tr>'+
    		'	</table>'+
    		'</form></div>';
    		//$(ContentString).appendTo('.textwidget');
    		$('#text-9').html(ContentString);
    		$('#text-9').attr('style', 'margin-top: 0px');
    	});
    </script>
Viewing 13 replies - 1 through 13 (of 13 total)