Jump to content

bsandall

Member
  • Posts

    222
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by bsandall

  1. The way the 'Featured Products' section works is that it selects one random product from among all that are marked as featured in the database.

    If you set your 3 products as featured, each time the page loads one from among those 3 will be shown.

    If you would like to show all 3 at once, that will require editing both the back end (probably category class) and the front end (the skin).

    On the back end, just find wherever the featured product is selected and change it to have no limit or a larger limit, and return an array of all the found products.

    On the front end, iterate through that array and display them in a column similar to how 'Sales Products' are displayed.

  2. I'm not sure how the session cleanup is supposed to work, but it doesn't appear to be working.

    After setting the session save_path manually in cPanel, and making only that one change, sessions are getting stored in CubeCart's includes/extra directory, which they weren't before, even though that is not the path I specified.

    This directory is now full of sessions starting from 10/23. I'll check tomorrow to see if those get deleted - perhaps it's on a rolling 1-week basis.

  3. Oddly enough, my store is already set up to use the /extra folder, at least according to phpinfo.

    And yet, until I changed the setting via cpanel, my sessions were getting deleted after 20 minutes.

    Note that my cpanel setting is different than that in my CubeCart config, and always has been. The original was the default /tmp, to which I simply appended a new directory e.g. /tmp/new_but_unique_ish

    When I view files on the server, there are session files stored in both the CubeCart-specified directory and the /tmp directory (but not the new one, which I didn't actually create a directory for).

    Those in CC's directory are current, those in /tmp are from prior to me changing the directory in cPanel.

    Also of note is that the ones in CC's directory do not appear to be getting garbage collected as there are significantly more from today than any day still in /tmp.

    Thinking on this, it seems that cPanel's save_path counts as the path being specified as far as CubeCart is concerned, so CC's was not being used and I was stuck with the default. Viewing the files on my server, though, shows that the session save folder is definitely not shared with others - /tmp is in the same server directory as my /public_html folder.

    So... now I really have no idea what's going on. :P

  4. Thanks, Keat, that has lead me to what I believe is the solution.

    Turns out that on shared hosting, the site with the shortest session.gc_maxlifetime variable ends up cleaning out the entire sessions directory because there is no way for it to tell which session file belongs to which site. See this StackOverflow answer.

    I can only assume that a month or two ago, a new site was hosted with the default session lifetime and started cleaning up everyone's session files.

    By setting a custom session save path, I should be able to avoid this problem. I guess I'll know in 20 minutes! ;)

  5. It would be in one or more files in the skins/foundation/templates folder, such as in content.product.php.

    Search for e.g.:

    {$PRODUCT.price}

    And replace with e.g.:

    {if $PRODUCT.price == 0}Call for price{else}{$PRODUCT.price}{/if}

    Note that the price field at this point is typically formatted to e.g. '$5.00' and may change with selected currency, so you may be better off manipulating this at the server level.

    Either way, you run the risk of unintended consequences, so be sure to thoroughly test any changes you make before putting them live.

    I would also recommend using some sort of version control software, such as Git, to help you track your changes. This way you not only have a history of changes you've made that you can easily reapply when updating, but you also have that same history available to cross reference when debugging any mess you happen to create by editing the files - it's saved me a lot of time on many occasions. ;)

  6. First noticed on 6.1.10 and still happens on 6.1.12.

    Short periods of inactivity (20-30 minutes) cause me to automatically be logged out of the admin control panel.

    Note that this appears to only affect the live store (tested in both Chrome and FireFox). My locally hosted test site does not exhibit this behavior, which leads me to suspect it may not be CubeCart causing this issue.

    Is there perhaps a server setting that would be causing this to happen?

  7. 5 hours ago, havenswift-hosting said:

    I would always personally do it using phpMyAdmin but then I always do upgrades manually etc

    Same here.

    I always recommend compressing the database backup with 7-zip, winzip, etc. and then using phpMyAdmin's import tool to run it - it's very fast and can handle a LOT of data.

  8. 4 hours ago, havenswift-hosting said:

    Just taken a look at that script and it looks very good - a great contribution !  The warnings about security and protecting it from unauthorised access are important for anyone looking to use it otherwise something could make a real mess of your store but the documentation looks very good !

    Thanks! I wrote it for my own use and figured I'd toss it up on GitHub. It's not a pretty interface and some of the product warnings aren't useful / entirely accurate, but it gets the job done. ;)

    For the OP, it doesn't update stock levels, but with a little MySQL/PHP knowledge, it wouldn't be difficult to modify it to do so.

  9. 23 minutes ago, Dirty Butter said:

    We get customers who give us faulty email address quite frequently. I can see this being very useful, not just for these no longer valid free addresses.

    Your code works perfectly @bsandall But a returning customer may not go to the homepage. Can it be made to show on the Account page, which is what they see when they login?

     

    You could put it wherever you want, yes, provided you make sure to assign the customer group data to SMARTY before whatever page it is you want to display it on is loaded.

  10. Part of your problem may be that CubeCart doesn't by default share the customer group membership data with SMARTY, so the variable `$customer_membership` shouldn't even exist unless you have specifically set it yourself.

    Another issue is that fetching customer memberships would give you an array, not a single value, so it will never be equal to 2.

    This code will do what you need:

    // You can create a snippet for `class.cubecart.display_homepage` or just add this code
    // directly to `cubecart.class.php::displayHomePage()` around line 128:
    $GLOBALS['smarty']->assign('CUSTOMER_GROUPS', $GLOBALS['user']->getMemberships());
    
    // Then add the following to your `content.homepage.php` template, probably right before the {if $LATEST_PRODUCTS} line
    {if isset($CUSTOMER_GROUPS)}
    	{foreach from=$CUSTOMER_GROUPS item=group}
    		{if $group.group_id == 2}
    			<div class="small-12">
    				<p>Your message here</p>
    			</div>
    			{break}
    		{/if}
    	{/foreach}
    {/if}

     

  11. 1 hour ago, Dirty Butter said:

    It sure looks like this should have worked, but it doesn't.

    {if $customer_membership.group_id = '1'}

    If that is the correct variable (I haven't checked), the reason it isn't working is because you are using an assignment operator instead of a comparison operator. In other words, you are telling the code to set the group_id to equal 1, rather than checking if it is equal to 1.

    One example of correct syntax is:

    {if $customer_membership.group_id == '1'}

    Note the double equals sign (==) - this is the non-strict comparison operator which will evaluate to true whether group_id is the integer 1 or the string '1'.

  12. Create a code snippet using the hook `class.cart.add.preredirect` and add the following code:

    <?php
    $category_id = $GLOBALS['db']->select('CubeCart_category_index','cat_id',array('product_id'=>$product_id,'primary'=>1));
    if ($category_id) {
        $redirect_url = $GLOBALS['seo']->buildURL('cat', $category_id[0]);
        if ($redirect_url) {
           httpredir($redirect_url); 
        }
    }
    ?>

    This will cause the page to redirect to the main category of the product any time a user adds it to the basket and avoids entirely the JS-powered auto-display of the side basket (though this basket can still be displayed if the user specifically clicks on it).

    Do note, however, that the script above does not elegantly handle the case where the user adds a product from any page other than the product page, for example if they added a product to their basket from the home page. Should be enough to get you started, though.

  13. You can always find where Smarty variables are assigned by doing a global search for them in your CubeCart directory. On Windows, for example, open a console in said directory and run:

    findstr /i /n /s /c:"CHECKOUT_BUTTON" *.*

    The output will look something like this:

    classes\cubecart.class.php:571: $GLOBALS['smarty']->assign('CHECKOUT_BUTTON', true);
    classes\cubecart.class.php:1702: $checkout_button = (CC_SSL) ? $GLOBALS['language']->checkout['secure_checkout'] : $GLOBALS['language']->checkout['checkout'];
    .
    .
    .

    Usually you will have to actually open the files and read the code around the lines mentioned, but in this case you can probably safely conclude that the language entries you need to change are under checkout.secure_checkout and checkout.checkout.

    Also, you can search for 'checkout' in the definitions.xml file - you will see entries in both the basket and checkout groups; I do not know whether both need to be changed or just the ones in the checkout group, and there may be others (I stopped looking).

  14. 6 hours ago, Noodleman said:

    The queries probably shouldn't run on page load in this case, but perhaps on demand via a "refresh stats" button on the statistics page. This can then run the queries, gather the results from each and store the results in a database statistics table. the reports can then pull the derived values from the table rather than calculate it every time.  This isn't too much of an issue as it's only going to impact stores with a large data set.

    This was my option #1 if fixing the indexes didn't resolve it:

    On 5/17/2017 at 8:31 AM, bsandall said:

    1. Create a summary table (and regularly update it) containing a running tally of quantities sold so that the database doesn't have to actually SUM potentially tens of thousands of rows. This wouldn't be a bad idea for core CubeCart to implement.

    It can easily be kept up-to-date after the initial calculation whenever an order is created, modified, or deleted, perhaps with a total recalculation on demand feature.

  15. 4 hours ago, djcaseanova said:

    hosting company has me on a shared server, not sure how that would work. Is there a method I can use to force https in the htaccess? Is that the setting in the store settings to enable SSL?

    This is what I use in my .htaccess file - put this right after enabling the RewriteEngine and setting the RewriteBase:

    # Require SSL
    SSLOptions +StrictRequire
    SSLRequireSSL
    SSLRequire %{HTTP_HOST} eq "yoursite.com"
    ErrorDocument 403 https://yoursite.com
    
    # Require SSL without mod_ssl
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

     

  16. It looks like your database is missing some indexes - this could explain why your query is taking so long to run.

    Here are my results:

    id select_type table type possible_keys key key_len ref rows Extra  
    1 SIMPLE S range cart_order_id_2,status,cart_order_id status 1 NULL redacted Using index condition; Using temporary; Using file...
    1 SIMPLE O ref product_id,cart_order_id cart_order_id 56 S.cart_order_id 1 NULL
    1 SIMPLE I eq_ref PRIMARY PRIMARY 4 O.product_id 1 NULL

    Note the key 'status' in the first row with a key_length of 1; also note that row 2 returns rows on a 1-to-1 basis, whereas yours returned 96 products.

    I recommend you go through each of your tables and compare them to CubeCart's database setup file. You may also be able to check the indexes from your Admin's Maintenance tab.

    By the way, running the actual query only takes 0.0053 seconds for me.

    Other options to consider if fixing your table indexes doesn't work:

    1. Create a summary table (and regularly update it) containing a running tally of quantities sold so that the database doesn't have to actually SUM potentially tens of thousands of rows. This wouldn't be a bad idea for core CubeCart to implement.

    2. If you have control over the server hardware, you could swap in an SSD drive to store the database on, increase RAM, etc. to improve query speeds. If you cannot manage the hardware, you may still be able to contact your host and see if they have better options for you.

    3. Partition the table (look up table partitioning) so that there aren't such huge amounts of data to query against, especially since the Dashboard only cares about the most recent ones. I don't think this is actually a viable solution in your case, but it is a common practice when dealing with large amounts of data.

×
×
  • Create New...