Jump to content

Admin Created Orders - Now with Downloads!


bsmither
 Share

Recommended Posts

This is for CubeCart 5.2.2 -- the edits should be the same, but maybe with nearby line numbers, for other versions.

 

When the store owner administratively creates an order for a customer, and a digital product is added to that order, CubeCart does not attempt to also enable the ability for that customer to download that product.

After performing the following edits:
* When the admin moves the order from Pending to Processing (then, if this is a digital-only order, Cubecart moves it to Complete), CubeCart will email this message: Your Purchased Downloads with a viable link to the digital product.
* The link will also appear in the customer's Account page, Digital Downloads section.

I have not tested various permutations, such as, when adding a second digital product to a Completed order. Will emails be sent? What might happen to the existing digital product record in the CC_downloads table?

Note: If you find that downloads are expiring immediately or in the past, make sure you have the following settings:
* Store Settings, Stock tab, "Download expiry time (in seconds)" is blank or a number.
* Store Settings, Advanced tab, correctly chosen the timezone you want your business to be operating in. Also, you may not need to enter anything here, but the "UTC Offset" is the number of seconds between where the server hosting your site is located and the time where your business is located: earlier (positive) or later (negative) than you. To get a good idea of what you need to put in this field, immediately after you log-in as an admin, got to the Staff Access Log. Calculate the number of hours you need to add or subtract from the time shown to get the time desired and multiply that by 3600.


In the file, admin/sources/orders.index.inc.php:

Near line 67:

$GLOBALS['db']->update('CubeCart_order_inventory', $data, array('cart_order_id' => $order_id, 'id' => (int)$data['id']));

Add AFTER:

// Updating a download not necessary (I hope)

Near line 61:

            unset($record);
        }
    }
    // Update Products

Add BEFORE:

           // Also insert a download
            if(isset($record['digital']) && $record['digital']) {
                $record['customer_id'] = (isset($_POST['customer']['customer_id']) && !empty($_POST['customer']['customer_id'])) ? (int)$_POST['customer']['customer_id'] : 0;
                $record['accesskey'] = md5($order_id.(int)$data['product_id'].date('[email protected]').mt_rand());
                $record['expire'] = ($GLOBALS['config']->get('config', 'download_expire')>0) ? time() + $GLOBALS['config']->get('config', 'download_expire') : 0;
                $GLOBALS['db']->insert('CubeCart_downloads', $record);
            }

Near line 60:

$GLOBALS['db']->insert('CubeCart_order_inventory', $record);

Change to:

$record['order_inv_id'] = $GLOBALS['db']->insert('CubeCart_order_inventory', $record); // Capture inserted record id

Near line 40:

$GLOBALS['db']->delete('CubeCart_order_inventory', array('cart_order_id' => $order_id, 'id' => (int)$value));

Add AFTER:

// Also remove from downloads
$GLOBALS['db']->delete('CubeCart_downloads', array('cart_order_id' => $order_id, 'order_inv_id' => (int)$value));
Link to comment
Share on other sites

  • 4 weeks later...

  • 2 weeks later...

Thanks for the post Brian. I find the instructions a little ambiguous. Any chance the patched file can be attached to this post so I can do a file comparison and merge? I don't understand why there is instructions to add a comment "// Updating a download not necessary (I hope)" after the update on line 67? The rest seems ok but I need to be sure before potentially releasing this in the wild. 

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

Al ..This is the major bug for me since Cubecart 5.0 and should be added to the core as the way it is now it just don't works for digital orders created manually by the admin as no download link are send by e-mail or showing up in the download account section .

I bothered Brian with this problem since I upgraded to cc5 , so thanks for the fix mate 

there is still problem with resetting digital orders made previously using cc version 4 + and after upgrade to cc5 there is no way to reset them at all and I am doing it manually with more than 3K customers on a daily basic 

Link to comment
Share on other sites

  • 6 months later...
  • 11 months later...

The instructions should apply to CC605, but the line numbers have changed.

In the file, admin/sources/orders.index.inc.php:

Near line 88, find:
$GLOBALS['db']->update('CubeCart_order_inventory', $data, array('cart_order_id' => $order_id, 'id' => (int)$data['id']));

Add AFTER:
// Updating a download not necessary (I hope)

Near line 79, find:
            unset($record);
        }
    }
    // Update Products

Add BEFORE:
           // Also insert a download
            if(isset($record['digital']) && $record['digital']) {
                $record['customer_id'] = (isset($_POST['customer']['customer_id']) && !empty($_POST['customer']['customer_id'])) ? (int)$_POST['customer']['customer_id'] : 0;
                $record['accesskey'] = md5($order_id.(int)$data['product_id'].date('[email protected]').mt_rand());
                $record['expire'] = ($GLOBALS['config']->get('config', 'download_expire')>0) ? time() + $GLOBALS['config']->get('config', 'download_expire') : 0;
                $GLOBALS['db']->insert('CubeCart_downloads', $record);
            }

Near line 78, find:
$GLOBALS['db']->insert('CubeCart_order_inventory', $record);

Change to:
$record['order_inv_id'] = $GLOBALS['db']->insert('CubeCart_order_inventory', $record); // Capture inserted record id

Near line 55, find:
$GLOBALS['db']->delete('CubeCart_order_inventory', array('cart_order_id' => $order_id, 'id' => (int)$value));

Add AFTER:
// Also remove from downloads
$GLOBALS['db']->delete('CubeCart_downloads', array('cart_order_id' => $order_id, 'order_inv_id' => (int)$value));

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...