New Landing How can we help? Cardinal Support for anonymous backers in crowdfunding layout

Viewing 11 posts - 1 through 11 (of 11 total)
  • Posted in: Cardinal
  • #89619
    m0majeed
    Member
    Post count: 18

    Hey guys,

    I’m currently using this theme for my crowdfunding site and user have realised that there isn’t an option for anonymous backers.

    To remain anonymous when pledging, at the checkout there is a box which needs to be ticked.

    How can I add support for this in Cardinal?

    #89620
    m0majeed
    Member
    Post count: 18
    This reply has been marked as private.
    #89621
    m0majeed
    Member
    Post count: 18

    In the crowdfunding plugin there is this, if you look at the end there is the option for anon backers:

    /**
     * Track number of purchases for each pledge amount.
     *
     * @since Astoundify Crowdfunding 0.9
     *
     * @param int $payment the ID number of the payment
     * @param array $payment_data The payment data for the cart
     * @return void
     */
    function atcf_log_pledge_limit( $payment_id, $new_status, $old_status ) {
    	global $edd_logs;
    
    	// Make sure that payments are only completed once
    	if ( $old_status != 'pending' )
    		return;
    
    	// Make sure the payment completion is only processed when new status is complete
    	if ( in_array( $new_status, array( 'refunded', 'failed', 'revoked' ) ) )
    		return;
    
    	if ( edd_is_test_mode() && ! apply_filters( 'edd_log_test_payment_stats', false ) )
    		return;
    
    	atcf_update_backer_count( $payment_id, 'increase' );
    }
    add_action( 'edd_update_payment_status', 'atcf_log_pledge_limit', 100, 3 );
    
    function atcf_update_backer_count( $payment_id, $direction ) {
    	$payment_data = edd_get_payment_meta( $payment_id );
    	$downloads    = maybe_unserialize( $payment_data[ 'downloads' ] );
    
    	if ( ! is_array( $downloads ) )
    		return;
    
    	foreach ( $downloads as $download ) {
    		$variable_pricing = edd_get_variable_prices( $download[ 'id' ] );
    
    		foreach ( $variable_pricing as $key => $value ) {
    			$what = $download[ 'options' ][ 'price_id' ];
    
    			if ( ! isset ( $variable_pricing[ $what ][ 'bought' ] ) )
    				$variable_pricing[ $what ][ 'bought' ] = 0;
    
    			$current = $variable_pricing[ $what ][ 'bought' ];
    
    			if ( $key == $what ) {
    				if ( 'increase' == $direction ) {
    					$variable_pricing[ $what ][ 'bought' ] = $current + 1;
    				} else {
    					$variable_pricing[ $what ][ 'bought' ] = $current - 1;
    				}
    			}
    		}
    
    		update_post_meta( $download[ 'id' ], 'edd_variable_prices', $variable_pricing );
    	}
    }
    
    function atcf_edd_purchase_form_user_info() {
    	if ( ! atcf_theme_supports( 'anonymous-backers' ) )
    		return;
    ?>
    	<p id="edd-anon-wrap">
    		<label class="edd-label" for="edd-anon">
    			<input class="edd-input" type="checkbox" name="edd_anon" id="edd-anon" style="vertical-align: middle;" />
    			<?php _e( 'Remain anonymous? Hide name on donors list?', 'atcf' ); ?>
    		</label>
    	</p>
    <?php
    }
    add_action( 'edd_purchase_form_after_user_info', 'atcf_edd_purchase_form_user_info' );
    
    /**
     * Save if the user wants to remain anonymous.
     *
     * This is up to the theme to actually honor.
     *
     * @since Astoundify Crowdfunding 1.2
     *
     * @param arrray $payment_meta Array of payment meta about to be saved
     * @return array $payment_meta An updated array of payment meta
     */
    function atcf_anon_save_meta( $payment_meta ) {
    	$payment_meta[ 'anonymous' ] = isset ( $_POST[ 'edd_anon' ] ) ? 1 : 0;
    
    	return $payment_meta;
    }
    add_filter( 'edd_payment_meta', 'atcf_anon_save_meta' );
    
    #89676
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Have added this to the list for an update, hopefully the next update, but might slip to the one after – will do my best!

    – Ed

    #89681
    m0majeed
    Member
    Post count: 18

    Thanks man, let me know if you need it tested.

    #89826
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    No problem

    – Kyle

    #90546
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Just written up this functionality ๐Ÿ™‚

    – Ed

    #90557
    m0majeed
    Member
    Post count: 18

    Nice one! ๐Ÿ˜‰ Can’t wait to try it out.

    #90560
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hoping to release the update next week – the feature list is awesome ๐Ÿ™‚

    – Ed

    #92399
    m0majeed
    Member
    Post count: 18

    Hey Ed,

    This wasn’t added to the most recent update did it?

    #92451
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    The big update is going out today and this will be included ๐Ÿ™‚

    – Kyle

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register