• Content count

  • Joined

  • Last visited

Community Reputation

7 Neutral
  1. I am building an own-use module that offers a choice from a largish table of options that may change over time. It makes sense to: Initialise this table during module installation Offer a maintenance dialog to add new options down the track The benefit of initialisation is that all sandpit, development, test and production systems will have the same initial set of data; I won't have to initialise it manually; Eliminates opportunities for error when setting up a new system I studiously cribbed the example provided by SWFS Product Dimensions - viz: if(!$module_config = $GLOBALS['config']->get('sfws_product_dimensions')) { $module_config = array ( 'dimensions_unit' => 'cm', 'display_length' => true, 'display_width' => true, 'display_height' => true, 'display_package_count' => true, 'product_page_tab' => true, 'product_page_specifications' => true, 'product_page_other' => false, 'status' => true ); $GLOBALS['config']->set('sfws_product_dimensions','', $module_config); $record = array ( 'module' => 'plugins', 'folder' => 'SFWS_Product_Dimensions', 'status' => '1', ); $GLOBALS['db']->insert('CubeCart_modules', $record); $GLOBALS['main']->setACPNotify("The 'Product Dimensions CC6 Plugin' configuration has been installed."); $redirect_status = 1; } To initialize the table, I cooked up this monster: if(!$module_config = $GLOBALS['config']->get('testModule')) { $module_config = array ( 'products' => array ( array ( 'id' => 1, 'active' => true, 'colour' => 'Red', 'flavour' => 'Chilli, avocado and broccoli', 'priority' => 1 ), array ( 'id' => 2, 'active' => true, 'colour' => 'Grey', 'flavour' => 'Pineapple, turnip and liver', 'priority' => 2 ) ) ); $GLOBALS['config']->set('testModule','', $module_config); } if ($redirect_status == '1') { httpredir(currentPage()); } $module = new Module(__FILE__, $_GET['module'], 'admin/index.php', true); $page_content = $module->display(); The module class should deliver an array named MODULE_DINNER to the Smarty template, but it never arrives. If I remove the bang from the if statement to get if ( $module_config = $GLOBALS['config']->get('testModule') ) then the table is displayed when I enter the form (for example by clicking the module name in the breadcrumb trail at the top of the page) but it is not when I click Save. I believe the template is working perfectly because it displays correctly when MODULE_DINNER is available, so the problem is in the logic of the PHP module. Refining the code above to: if($module_config = $GLOBALS['config']->get('testModule') && !isset($module_config['products])) { $module_config['products'] = array ( array ( 'id' => 1, provides an amusing variation on the existing disfunction, but makes no real difference. The theory of what is happening above is that the module config is initialised before the module class is instantiated. Therefore the module reads the updated config, builds $MODULE, which contains the scalar config values, and creates MODULE_<KEY> for all module config entries that are arrays. The effect that I am seeing is: if the config does not exist already, it is not saved by $GLOBALS['config']->set(. The Save action Clearly I am doing something wrong, and given an infinite amount of time, I may well be able to work it out, but I have spent more hours than I can spare on it so far, so expedience over-rules pride and I am <sob!> asking for help, hoping that someone has managed to get this to work already. My heart is in your hands... There must be a pattern for this already, right? I can find lots of examples that manage scalars, but I have not found a module that initializes a table that has visible code. Thank you for your help. Russ
  2. Howdy, I am updating to CubeCart 6 from 4.3.4. It is complicated because my 4.3.4 installation is somewhat modified which is why I am still on 4.3.4. However, I'm all grown up now and I don't want to make the same mistakes again. I am developing my custom code as extensions. This has several benefits, even if I don't share them. Mainly, coding an extension means it will plug itself tidily into any new sandpit environments I create with no effort on my part. However... I am having trouble working out what is going on behind the curtains for the admin pages. By inspection, I have determined that the coding pattern is: Add any new tables that do not already exist. Add any new fields that do not already exist. Instantiate a module with $module = new Module(__FILE__, $_GET['module'], 'admin/index.tpl', true); Display the template with $page_content = $module->display(); Clearly there is a lot going on under the hood because the location of the template is not explicitly declared, and the global config is provided and saved automatically. All the template has to do is flash up the configuration page, drawing values from a magically created $MODULE array then assign the results to an output array called "module" and the results are somehow magically saved. This is fine provided (a) you don't want to initialise the config scalars and (b) you don't want to do anything dramatic such as initialise a table of config values. Which, of course, I do. The institutional IT guy in me desperately does not want to have to reverse-engineer all this to figure out how it works. I have looked at a mess of extensions and none of them seem to do anything dramatic except SFWS_Product_Dimensions which does some pre-initializations, but when I copy and hack it just the tiniest bit, it does not work - my values to not get added to the global config and the initialisations are not persisted. Is there any documentation on this anywhere? I have been thrashing around intermittently for a couple of days and it is starting to really annoy men. It is just too ghastly to think that everyone wanting to use this magnificent facility has to reverse engineer the entire thing before they become productive. Thanks for your help, Russ
  3. I recently made a rare purchase from Amazon. I also recently made a rare decision to upgrade from CC 4 to CC 6. CC 6 is beautiful. I love it. Except the checkout process. Everything is there but it is monolithic. The Amazon approach is phased across multiple pages approximately as follows: Review cart Enter billing address Optionally enter delivery address Select shipping options Enter payment information Review summarized information with option to change everything Commit CubeCart has all this, but it is on just two pages, one of which is optional: View Cart Check-out I believe Smarty will allow something more like the Amazon solution merely by changing the template Is there an existing template that already has something like this? My vision is: Review Cart (always) - including shipping quote according the current solution (with adjustments noted elsewhere) This gets us the country and postcode from which we derive the region And it completes the shipping method solution so we have a finalised order right here, on one clean, simple and beautiful page. Provide billing address there is a "Back to Basket/Cart" button there is an "I want to deliver to a different address" button there is a "Check out" button Optionally provide delivery address there is a "Back to billing address" button there is a "Back to Basket/Cart" button There is a "Check out" button Check out Start with "Would you like to save these details for next time?" If so, enter passwords Saving details for next time is a statement of customer benefit. Create an account sounds like something that benefits us. The benefits are clearly listed You wont have to enter address details next time. You can save multiple billing and delivery addresses You can see your order history You can reprint receipts and invoices any time You can create and park an order, then review it and pay later Then solicit permission to send newsletters Then select payment method or offer to park the order. All three sections have large clear headings. Summary List the cart, shipping information, account status (including username) payment method Buttons or links to revise any part of the order Buy or Park for later payment: Park is useful if the customer is having card trouble, or if they need to query the shipping price. It is also useful for us if the shipping solutions do not deliver, in which case, park is the only option. And it may be useful in other circumstances, for example where we have agreed to adjust the order in some way before payment. I use it for international shipments, because the price is heavily dependent on packed dimensions: Customer creates and parks order (I currently use the Direct bank deposit option for this, but it is somewhat misleading for the customer and requires explanation .) Ideally, at this point, the store sends an order confirmation. I work out the actual parcel size and weight, get a quote, adjust the shipping cost, notify the customer with instructions on how to find the parked order. Ideally, at this point, the store sends a notification of payment pending, with instructions. Customer chooses to proceed, logs in, pays. I ship.
  4. Shipping quotes before cart commitment

    Heavens to betsy... This will need some intervention. We definitely should not give an estimate until we know where the parcel is going. With my aforementioned Alice Springs example, the postage quote goes up by 3x when the postcode goes in. There are a bunch of potential customers who will find that very angryfying. That "Estimated" link is pretty subtle. I'm not a novice at this and I didn't guess it. It's an online store, not a gameified learning experience. On the other hand, once found it is very nice. Bouquets to the implementer, and a marshmallow brickbat to the interface designer. The interim solution has to be: initial state a snippet that checks if the "estimated" postcode is set, and if not, it hides the "select your shipping method" box. (minor coding change) change the link text from "Estimated" to "Get a shipping quote" (Text change) move the quote link to the location of the invisible "Select your shipping method" box. (Template change) User enters country and postcode (I presume the region is here because in some jurisdictions it determines the tax.) The shipping method dialog elements appear as now, but with an option to "Change your quote" below the list box. (Coding change to switch the text - template probably does not change,) Does that make sense? R
  5. Shipping quotes before cart commitment

    After due reflection I am thinking that the neatest correct answer here is to have "View Basket" and "Checkout" do the same thing for anonymous users, which is take the punter to the nice, clean "View Basket" page, where added Country, Postcode fields are abetted and abutted by a "Quote Postage" button. The punter can choose to skip the quote and Checkout, or enter the postcode and country (which defaults appropriately) to get a quote. The first page of checkout has quite enough on it already so there is no need to make it busier. For account customers, we already have their details, so we can provide postage automatically. If the punter chooses to get a quote, the postcode and address information should be populated into the address fields of the next window. Incidentally, if the customer nominates a delivery address, I think it should start out defaulted to the billing address because often they are very similar - home address for billing, work address in the same town for delivery, for example. Post box for billing, house address in the same town for delivery. The names and contact details are generally the same. Thoughts? R
  6. Shipping quotes before cart commitment

    That's amusing - it's the only field on that tab that isn't documented. I wonder what it does? Problem: Regardless of its value, and without a postcode selected, my anonymous user is getting a shipping quote that is offering a remarkably low price for delivery to anywhere in Australia (which seems to be selected by default automatically as the country in the address block.) There is no postcode information entered, so the postage module is making it up. I am running this particular query in a newly started Firefox browser. Firefox has never seen this installation before, so it is not using a previous login context. The cart really should be asking for a postcode and country before providing the estimates. (If the customer is in Alice Springs, the cheapest price is $42.) And without confirming the delivery country, it should not be quoting tax, in this case, since all prices are ex-tax. At this point in the dialog, the user has no idea that Australia is selected as the default because the address block is not yet displayed. The case below should show the cart items and the subtotal only, since it is purely about confirming the adjusted quantities. There is nowhere here to enter address information for the cart to derive tax and postage. Tax should only be displayed once the jurisdiction is known. Shipping costs should only be displayed once the postal code and country are both known. To add clarity, I disabled the Store Collection option and I now get $11.41 as the default selection in the list box. Bsmither - can you confirm this behaviour on one of your many installations? Preferably one of the few that has not been monkeyed with in this area. The completely correct solution is to put a note under Shipping "To see shipping options, select a country and region above and enter a postcode" and under the tax block "To see taxes, please select a country in the address block above." The postcode, region and country boxes should be enclosed in a box caption "Complete these for a shipping and tax quote". Problemette 2: The checkbox "Deliver to billing address" seems non-intuitive to me - it really should be "Deliver to another address" and not selected. I can hack it. But I wish I didn't have to." Apparently-already-solved-problem 3: Why don't we have a "Continue Shopping" button in the cart like my existing 4.3.4 store, and all other non-communist online stores have. I see there is an enhancement request and a forum thread on this already, but I cannot work out what eventually happened. Do I use the bsmither amendment to action it myself? Russ
  7. Is there an existing plug-in that provides shipping quotes for ad-hoc customers? I am looking for something that allows a new customer to build a card then enter postcode and country to get a shipping quote and therefore a total price before they commit to the effort of building an account and parting with their personal details. Thank you for your advice, Russ
  8. Question: Does CubeCart really assume that each store has exactly one size of parcel for each shipping channel? Corollary: Is there really no way to provide a shipping method with actual dimensions other than by modification of the code? From inspection of a variety of postage interfaces for version 6, it seems all still assume a single size of box. Use of any other dimensions means hacking the interfaces because they do not contain any hooks. Parcel volume is essential when there is air travel or couriers involved, or when large, light objects (like foam iceboxes) are send by post and the postal service invokes volume pricing. Getting these wrong results in under-charging and potentially significant profit reductions. Tell me it is not so... If not, I feel an enhancement request coming on... Russ
  9. I am trying my hand at a wee plug-in. I have been tracking actual shipping costs in my 4.3.4 site and I want the same capability in 6.1. I have a report that lists shipping variances (the difference between shipping charged and shipping paid) so I can confirm that the shipping algorithms are tracking reality. I also export some CSV files that create the credit card purchases and payments in the accounting system that pay for over-the-counter shipping charges. Saves quite a bit of accounting time. Rather than dump myself into the vat of boiling oil that is un-upgradable software (again), I have decided to do it as a plug-in. Build some character, learn new tricks, that kind of thing. I did the obvious thing which is to pay a pound for that splendid worked example, Semper Fi's ever faithful product dimensions mod. I have created (in the COBOL sense of cloned and changed) a new plug-in. The admin page is up, and it looks fine in its limited way. However I noticed that although my plug-in is listed in the Settings - Languages - EN_UK drop-down list, there are no texts listed, whereas they exist for the Product Dimensions plug-in. My texts are definitely used by my page - I can change them in the XML file and the changes appear on the page after a refresh. What is required to register the texts with the language maintenance tool? Thanks for your help, Russ
  10. Steps to define a new hook

    I am developing a sequential order number solution and it seems like the right thing to do to create it as a plug-in so it can be shared if it gets off the ground. i have requested a hook at the appropriate place throug github, but until that materialises (probably the wrong word for software) I would like to add a custom hook so I can enjoy the whole developer experience. Is it enough to copy a nearby hook,then paste it with an adjusted name into the appropriate place? Is there any other declaration required on the provider side? I have read that the hooks.xml file is an info-only document, so I believe I don’t have to update that for a personal hook. Gotta say the whole hook/plug-in/snippet caper is a work of inspired genius, probably just one rung below the recent synchronised Falcon 9 Heavy booster landings. Full accolades to the perpetrators. I plan to use it for all my mods. Russ
  11. Oh, and bad me... Thank you, Whiskered One. You are like a geeky god to all of us.
  12. That did it. Now the mystery bar is gone. The enhancement added it. Will troubleshoot and contact the enhancement provider.
  13. Aha! The dreaded rogue <div>. I have just realised that my attempt to reinstate the original content.catalog.php has failed. I can see it is correct in terminal, and have cleared the caches and restarted apache, but still, it is using hte updated version. So therefore I clearly have not done one of these things at all... Stand down while I sort this out.
  14. Process for requesting a new code hook

    Thank you. I suspected as such, but I did not want to break protocol by doing the wrong thing. In the meantime I will proceed as above and back-port it if and when an official implementation is created. Thank you for your advice. So where are you? Probably not far from where I am, I suspect. Or you don't sleep...
  15. My existing store uses sequential order numbers. The coding for this is relatively trivial. I would like a code hook added to the createOrderId method of order_class. How does one go about requesting such things? I am thinking of something along these lines: -----------------------------------------8<----------------------------------------- public function createOrderId($return = false, $set_basket = true) { // Self-explainitory really... $this->_order_id = ""; <!-- Call hook here --> if ($this->_order_id == "") $this->_order_id = date('ymd-His-').rand(1000, 9999); if ($set_basket) { $this->_basket['cart_order_id'] = $this->_order_id; /* fix for admin generated orders */ if (method_exists($GLOBALS['cart'], 'save')) { $GLOBALS['cart']->save(); } } return ($return) ? $this->_order_id : true; } -----------------------------------------8<----------------------------------------- And while we are in there, we can fix the spelling of "explanatory". Kill two birds with one check-in...