This patch will enable me to tag flexicharge as 4.7. Basically it is two changes

1) cart_checkoutapi()
There is more control over the generation of subtotals lines (and little things like suppressing a subtotal if it is right before the total. Also, it allows hook_checkoutapi implementers to use callbacks so that calculations can be made based on other things in the cart.

2) store_calc_gross()
Because the invoice total is calculated separately here, we mirror the way cart_checkoutapi calculates the total.

My fingers crossed!

Comments

sime’s picture

flexicharge currently in HEAD can be installed and used on top of this patch.

However, there is a bug preventing the charges saving to ec_transaction_misc on review page submit. But I assume the problem is in flexicharge.

sime’s picture

Status: Active » Needs review

Yes, and marking needs review.

hendrakieran’s picture

i'm not sure if the following can be considered as flexicharge, but what i'm looking for is to be able to automatically increase the price by certain constant amount with the decrease in stock (with an option to reset the counter on daily basis).

For example, on Sep 12, I have 50 units of item XYZ, with the initial price of $19.95, I'd like to increase the price by 5cents for every next order till end of the day, so the 1st customer will pay $20, the next one gets it at $20.05, and so on. And if I set it to reset after a day, on Sep 13, if there is something left in the stock, they initial price will be set as $19.95 again.

The rational behind this is to give some kind of incentive for customers place an order early.

Possible? or am i not making any sense ;)

sime’s picture

This makes sense. The idea of flexicharge is to implement a nice framework for interacting with the cart. So at the point of calculating the cost, a "provider" .inc file (in the "providers" directory) could query the transaction table for previous sales that day and then provide a price accordingly.

You still need to work out the logic, but once there are a few charge providers created, people should be able to model new charges on existing onces, tweaking the calculations as required.

hendrakieran’s picture

sime, thanks for the quick response!

i have yet to use this flexicharge module , so may I have the advantage of asking you whether the charging model i mentioned above can be implemented immediately? What kind of modification is required?

Thanks in advance.

sime’s picture

No it can't. Both because flexicharge itself is reliant on the cart patch in this thread, and also because the charges so far are only a basic number of simple charges (+/-% etc).

redinkdesign’s picture

I just attempted to apply this patch which resulted in this message..

patch -p0 < flexicharge_store_cart.patch
patching file cart/cart.module
Hunk #1 FAILED at 707.
1 out of 1 hunk FAILED -- saving rejects to file cart/cart.module.rej
patching file store/store.module
Hunk #1 succeeded at 2508 (offset -3 lines).

Contents of cart.module.reg

***************
*** 707,725 ****
          $txn->subtotal += $subtotal;
        }
  
        $form['totals'] = array();
        if ($txn->misc) {
          foreach ($txn->misc as $misc) {
            if (!$misc->seen) {
-             // Only add the subtotal line if there are other items in misc.
-             if ($form['totals']) {
-               $form['totals'][] = array('#title' => t('Subtotal'), '#value' => $txn->subtotal);
              }
-             $form['totals'][] = array('#title' => t($misc->description), '#value' => $misc->price);
            }
          }
        }
- 
        $form['totals'][] = array('#title' => t('Total'), '#value' => $txn->gross);
  
        $form = array('cart' => $form);
--- 707,762 ----
          $txn->subtotal += $subtotal;
        }
  
+       // Since we may remove items, keep a track of the current key.
+       $line = 0;
+       // Keep track of which lines are subtotals.
+       $st = array('#row_type' => 'ST');
+ 
+       // Create a subtotal line.
+       // If the Total comes immediately afterwards, then it will be repressed later.
+       $form['totals'][$line++] = array('#title' => t('Subtotal'), '#value' => $txn->subtotal, 'info' => $st);
+ 
        $form['totals'] = array();
        if ($txn->misc) {
          foreach ($txn->misc as $misc) {
+ 
            if (!$misc->seen) {
+             // Subtotal
+             if ($misc->subtotal_before && ($form['totals'][$line-1]['info']['#row_type'] != $st['#row_type'])) {
+               $form['totals'][$line++] = array('#title' => t('Subtotal'), '#value' => $txn->subtotal, 'info' => $st);
+             }
+           }
+ 
+           // Do this just like store_transaction_calc_gross.
+           if (function_exists($misc->callback)) {
+             $f = $misc->callback;
+             $amount = $f($txn, $misc, $txn->subtotal);
+           }
+           elseif ($misc->qty) {
+             $amount = ($misc->price * $misc->qty);
+           }
+           else {
+             $amount = $misc->price;
+           }
+           if(!$misc->already_added) { $txn->subtotal+= $amount; }
+ 
+           if (!$misc->seen) {
+ 
+             // Misc Item
+             $form['totals'][$line++] = array('#title' => t($misc->description), '#value' => $amount);
+             // Subtotal
+             if ($misc->subtotal_after) {
+               $form['totals'][$line++] = array('#title' => t('Subtotal'), '#value' => $txn->subtotal, 'info' => $st);
              }
            }
          }
        }
+ 
+       // Remove any subtotal occurring before the total.
+       if ($form['totals'][$line-1]['info']['#row_type'] == $st['#row_type']) {
+         unset($form['totals'][$line-1]);
+       }
+       // Grand total
        $form['totals'][] = array('#title' => t('Total'), '#value' => $txn->gross);
  
        $form = array('cart' => $form);

My cart.module and store.module versions...
cart.module,v 1.133.2.6 2006/09/09 03:18:14
store.module,v 1.125.2.13 2006/09/09 03:18:14

redinkdesign’s picture

I just attempted to apply this patch which resulted in the following message:

patching file cart/cart.module
Hunk #1 FAILED at 707.
1 out of 1 hunk FAILED -- saving rejects to file cart/cart.module.rej
patching file store/store.module
Hunk #1 succeeded at 2508 (offset -3 lines).

I'm using
cart.module,v 1.133.2.6 2006/09/09 03:18:14
store.module,v 1.125.2.13 2006/09/09 03:18:14

sime’s picture

StatusFileSize
new3.84 KB

Patch updated to latest 4.7

redinkdesign’s picture

Maybe it's just me..but cart.module still wont patch...any ideas if I'm doing something wrong?

*****
patch -p 0 < store_cart.patch
patching file cart/cart.module
Hunk #3 FAILED at 722.
1 out of 3 hunks FAILED -- saving rejects to file cart/cart.module.rej
patching file store/store.module

*****
sime’s picture

Hmm, this time the file versions don't seem to be to blame. So cart failed and store was OK?

For reference you are still using cart version 1.133.2.6 . Also, are you using CVS on command line?

I have had some issues with eclipse the last couple of days, so I am right now installing the latest version.

redinkdesign’s picture

Hey, I'm using command line patch -p0 < patch file

store.module patches fine, but cart.module doesnt...
as for the version #'s

cart.module,v 1.133.2.6 2006/09/09
store.module,v 1.125.2.13 2006/09/09 03:18:14

1 of 3 chunks failed...
Can you just post up your modified cart.module file?

sime’s picture

StatusFileSize
new33.39 KB

There is cart

sime’s picture

StatusFileSize
new4.3 KB

Here is another attempt at a unified patch. Hopefully I've sorted out the issues.

chueewowee’s picture

this patch failed me with the cart.module in flexicharge2

neclimdul’s picture

StatusFileSize
new3.76 KB

hopefully this works. hand patched the previous patch and diffed.

havoc’s picture

The patch attached to #16 worked flawlessly on my 4.7 install.

woot!

havoc’s picture

Status: Needs review » Reviewed & tested by the community

oops forgot to update to "ready to be committed"

sime’s picture

StatusFileSize
new4.03 KB

syswillim
Try this attached threshold.inc

You'll need to get the latest flexicharge module out as well.

sime’s picture

Version: 4.7.x-1.x-dev » master
Status: Reviewed & tested by the community » Active

Patched 4.7, yay. http://drupal.org/cvs?commit=41163
Changing to cvs to get that patched when I'm happy with how it's going.

dkashen’s picture

Title: cart patch to enable flexicharge 4.7 » up to date instructions for flexicharge ?

Hi,
I'm using drupal 4.7 and would like to try to setup flexicharge
for very much the same reasons that the author started it.

I know all the information is here, but some of it seems outdated.
Would someone please take a moment and layout the steps needed to install flexicharge ?
What to patch
and where to get the latest cvs version ?

Thanks,

dkashen’s picture

For example,

I think in the ecommerce cvs distribution, both the store and cart
modules are newer:
$Id: cart.module,v 1.133.2.9 2006/09/25 13:52:52 sime Exp $
$Id: store.module,v 1.125.2.14 2006/09/25 13:52:52 sime Exp $

than the patches and cart.module presented in the above thread. All my attempts, have
generated confusing patch errors and other drupal error.

Thanks for any help,

sime’s picture

Title: up to date instructions for flexicharge ? » cart patch to enable flexicharge CVS

Yes, I will be doing some instructions soon.

Just briefly for now, use flexicharge from CVS with 4.7 E-commerce. As mentioned above, you now do not need to patch store and cart, that is done.

You then need to go to administer -> store -> settings -> flexicharge

Then take a product to the checkout review screen to see the results.

redinkdesign’s picture

My subtotals dont reflect the flexicharge. I'm using site wide to test and I'm setting it at 15%. All I see is Site wide: 0.00.

dkashen’s picture

thanks for getting back.
after using the latest CVS version of ecommerce,
I placed the CVS flexicharge (comprised of)
flexicharge/flexicharge.info
flexicharge/flexicharge.install
flexicharge/flexicharge.module

in the contrib directory,
and chmod -R a+r (after getting a permission error).

Then I went, admin_modules and enabled flexicharge.

However, admin_store_settings doesn't show any flexicharge options.
Just these:

Store module dependencies
Module name Status
address Installed
parcel Installed
payment Installed
paypal Installed
product Installed
shipping Installed
cart Installed
tangible Installed
file Installed

I'm stuck.
Please help,
thank you,

sime’s picture

ok, when you go to administer > store > settings via the menu, now look at the actual menu, in the menu you should see a flexicharge link

sime’s picture

I've just updated flexicharge module to fix a problem with saved transactions not storing the charge.

dkashen’s picture

StatusFileSize
new18.43 KB

Hi,
I stepped through everything.
reinstalling ecommerce and flex from the latest CVS.
The only thing that said flexicharge was the checkbox option in
admin_modules (which I enabled).

Both the "actual menu" in the middle content block,
and the
administer > store > settings navigation block that's usually in a side bar
do not show anything with flexicharge.

I'll try another clean install of drupal, then ecommerce and flexicharge to see if that changes things.

Thank you,

dkashen’s picture

StatusFileSize
new30.56 KB

Hi,
from a clean drupal install
with latest cvs and flexicharge modules (installed under the contrib directory)
I still don't see the admin_store_settings.
I've enclosed a snapshot of the admin navigation with the pertinent subcategories
expanded.

Thank you,

sime’s picture

Hmm

So are you able to go directly to:
http://example.com/?q=admin/store/settings/flexicharge
?

dkashen’s picture

StatusFileSize
new24.01 KB

Hi,
I should have thought of that direct access.
anyway, from what I see (attached)
I'm still in nullsville.

Thanks for responding,

dkashen’s picture

oh,
and flexicharge is enabled in
admin_modules.

dkashen’s picture

a few debug points,
Fantastico is now installing 4.7.3 ,
so I decided to use that install instead of the manual one I've been doing.
There was a slight difference in the resulting
/files/.htaccess file

other than that. same steps. default install, CVS of ecommerce installed in
modules/ecommerce directory
and flexicharge installed at
modules/ecommerce/contrib/flexicharge

admin_modules is happy with both ecommerce and flexicharge.

I didn't see anything suspicious, but perhaps the above can rule something out.
THx.

sime’s picture

It seems odd to me that only flexicharge is not showing up. I don't really have any clues unless I am able to access the system directly.

sime’s picture

I couldn't reply to your email because your inbox is full. But the answer is "yes I'd like to look"

mrmachine’s picture

ok, i got to this thread via this thread: http://drupal.org/node/68363 which has as it's original attachment the shipbasic module, which i downloaded and installed on a drupal 4.7.3 site with latest ecommerce package ... it looked exactly like what i need - i'm building a site for my mum's shop, which is located in Australia, so the default ecommerce shipping modules are useless for us ... we just need something that allows us to set a shipping charge for each product, nothing fancy. but shipbasic never adds the charges to the review page.

i get the feeling that the shipbasic module was integrated/replaced with the flexicharge module, but if that's the case, i can't figure out how to just do something simple like just be able to add a shipping charge to each product without using the UPS and american stuff.

can someone tell me what modules/versions of modules i need to achieve something so basic to a shopping cart?

sime’s picture

Status: Active » Closed (fixed)

housekeeping, this will happen as a matter of course