Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Arbitrary Fee System Class #418

Closed
pippinsplugins opened this Issue Oct 13, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@pippinsplugins
Copy link
Member

pippinsplugins commented Oct 13, 2012

After talking with Jonathan Davis from Shopp for a while during WordCamp Louisville and have decided that it would be a great idea to write a class for applying arbitrary fees to purchases.

These fees would taxes, shipping (not really), and anything else.

One example that this could be used for is adding a fee during checkout if a user wants to purchase hosting as well.

@chriscct7

This comment has been minimized.

Copy link
Member

chriscct7 commented Dec 17, 2012

+1

pippinsplugins added a commit that referenced this issue Feb 8, 2013

pippinsplugins added a commit that referenced this issue Feb 8, 2013

pippinsplugins added a commit that referenced this issue Feb 8, 2013

@pippinsplugins

This comment has been minimized.

Copy link
Member Author

pippinsplugins commented Feb 8, 2013

Initially I've added the display of fees in checkout via the class, but I think instead I want to add them to the actual checkout template, just to make them easier to customize.

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

Refactored class to use SESSION var to ensure fees are persistent acr…
…oss page loads. Store fees in payment meta. #418

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

pippinsplugins added a commit that referenced this issue Feb 9, 2013

@pippinsplugins

This comment has been minimized.

Copy link
Member Author

pippinsplugins commented Feb 9, 2013

This is done, at least for the initial version. Here's an example of how it could be used:

function set_admin_discount() {
    if( current_user_can( 'manage_options' ) ) {
        $amount = edd_get_cart_subtotal() * 0.20;
        $amount = $amount * -1;
        EDD()->fees->add_fee( $amount, 'You are an admin special!', 'admin_special' );
    }
}
add_action( 'init', 'set_admin_discount' );

Which would result in:

Screenshot from 2013-02-09 15:13:56

And

Screenshot from 2013-02-09 15:14:47

@pippinsplugins

This comment has been minimized.

Copy link
Member Author

pippinsplugins commented Feb 9, 2013

For payment gateways, there is also a new "fees" array available in $purchase_data:

// Setup purchase information
$purchase_data = array(
    'downloads'    => edd_get_cart_contents(),
    'fees'         => edd_get_cart_fees(),              // Any arbitrary fees that have been added to the cart
    'subtotal'     => edd_get_cart_subtotal(),          // Amount before taxes and discounts
    'discount'     => edd_get_cart_discounted_amount(), // Discounted amount
    'tax'          => edd_get_cart_tax(),               // Taxed amount
    'price'        => edd_get_cart_total(),             // Amount after taxes
    'purchase_key' => strtolower( md5( uniqid() ) ),    // Random key
    'user_email'   => $user['user_email'],
    'date'         => date( 'Y-m-d H:i:s' ),
    'user_info'    => $user_info,
    'post_data'    => $_POST,
    'cart_details' => edd_get_cart_content_details(),
    'gateway'      => $valid_data['gateway'],
    'card_info'    => $valid_data['cc_info']
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.