Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

piernas

Members
  • Posts

    700
  • Joined

  • Last visited

  • Days Won

    17

Everything posted by piernas

  1. Yes I'm learning about those singleton classes. USU 5 has hard to follow code for me and these are beyond my little knowledge for now. But it seems, when being called by the FWR_Language_Selection above, main class will try to initialize again, thus not founding the $page value. Maybe that FWR_Language_Selection class has to be a singleton class too? I'll try to dig on it.
  2. That's great @@clustersolutions, I'll try your fix for cache as soon as you deploy it. You may want to add multilanguage support from here: http://www.oscommerce.com/forums/topic/336702-ultimate-seo-urls-5-by-fwr-media/?p=1573463. I'm working on a hreflang module fo it too but for now I couldn't make it work. @@vampirehunter it needs to modify tep_href_link function and use it's own.
  3. This is my modified version of the class. I added one more argument ($type) to return a button set or a <meta> set: <?php class FWR_Language_Selection { protected $page; protected $mode; protected $get; protected $lng; protected $language; protected $root_path; protected $language_image_width = '64'; protected $language_image_height = '64'; protected $session_started; protected $language_code_array = array(); public function __construct( navigationHistory $navigation, $language, $lng = false, $session_started = false, $type ='button' ) { $navigation_data = array_pop( $navigation->path ); $this->page = $navigation_data['page']; $this->mode = $navigation_data['mode']; $this->get = $navigation_data['get']; $this->setLanguage( $lng ); $this->language = $language; $this->root_path = realpath( dirname( __FILE__ ) . '/../../' ) . '/'; $this->session_started = $session_started; $this->type = $type; } public function __toString() { if ($this->type == "button") { return $this->getLanguageSelectionHtml(); } elseif ($this->type == "hreflink") { return $this->get_hreflang(); } } protected function setLanguage( $lng ) { if ( ( false === $lng ) || ( !$lng instanceof language ) ) { include_once DIR_WS_CLASSES . 'language.php'; $this->lng = new language(); $this->setLanguageArray(); return $this->lng; } $this->lng = $lng; $this->setLanguageArray(); } protected function setLanguageArray() { foreach ( $this->lng->catalog_languages as $code => $unused ) { $this->language_code_array[] = $code; } } protected function get_hreflang() { foreach ( $this->lng->catalog_languages as $code => $data ) { if ( $data['directory'] == $this->language ) continue; $hlink = $this->buildLink( $current = false, $default = ( $code === DEFAULT_LANGUAGE ), $code ); $output = '<link rel="alternate" hreflang="' . $code . '" href="' . $hlink .'" />'; } return $output; } protected function getLanguageSelectionHtml() { foreach ( $this->lng->catalog_languages as $code => $data ) { $language_image_path = DIR_WS_INCLUDES . 'languages/' . $data['directory'] . '/images/icon_round.png'; if ( $data['directory'] == $this->language ) continue; // This should be moved to the language files: if ($data['name'] =="English"||$data['name'] =="German") { $prepos =" in "; }else{ $prepos =" en "; } $output .= '<div class="col-xs-1 col-fixed">'; $output .= '<div class="text-center col-fixed"><a href="' . $this->buildLink( $current = false, $default = ( $code === DEFAULT_LANGUAGE ), $code ) . '" title="' . tep_output_string_protected( $data['name'] ) . '">' . tep_image( $language_image_path, $data['name'], $this->language_image_width, $this->language_image_height,'','false') . '</a></div>'; $output .= '<div class="caption text-center col-fixed"><a href="' . $this->buildLink( $current = false, $default = ( $code === DEFAULT_LANGUAGE ), $code ) . '" title="' . tep_output_string_protected( $data['name'] ) . '" class="headerNavigation" >' . STORE_NAME . $prepos . tep_output_string_protected( $data['name'] ) . '</a></div>'; $output .= '</div>'; } return $output; } protected function buildLink( $current = false, $default = false, $code ) { if ( false === $this->session_started ) { return $this->multiLanguage( tep_href_link( FILENAME_DEFAULT, '', 'NONSSL' ), $current, $default, $code ); } return $this->multiLanguage( tep_href_link( $this->page, $this->getQuery(), $this->mode ), $current, $default, $code ); } protected function getQuery() { if ( tep_not_null( $this->get ) ) { if ( array_key_exists( tep_session_name(), $this->get ) ) { unset( $this->get[tep_session_name()] ); } return http_build_query( $this->get ); } return ''; } protected function removeQueryString( $target ) { if ( false === strpos( $target, '?' ) ) { return $target; } return substr( $target, 0, strpos( $target, '?' ) ); } protected function removeLanguageMarkers( $target, $cookie_path ) { $return = preg_replace( '@' . $cookie_path . '(' . implode( '|', $this->language_code_array ) . ')/@', $cookie_path, $target ); $return = preg_replace( '@' . $this->page . '/(' . implode( '|', $this->language_code_array ) . ')@', $this->page, $return ); return $return; } protected function multiLanguage( $link, $current, $default, $code ) { $server = ( $this->mode == 'NONSSL' ) ? HTTP_SERVER : HTTPS_SERVER; $cookie_path = ( $this->mode == 'NONSSL' ) ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH; $server = $server . $cookie_path; $link = $this->removeLanguageMarkers( $link, $cookie_path ); if ( false !== $default ) { $no_querystring = $this->removeQueryString( $link ); // Is the page FILENAME_DEFAULT and after the querystring is removed is FILENAME_DEFAULT the ending characters of the URL, if so we chop it off leaving just the domain if ( ( $this->page == FILENAME_DEFAULT ) && ( substr( $no_querystring, ( strlen( $no_querystring ) - strlen( $this->page ) ), strlen( $no_querystring ) ) == $this->page ) ) { return str_replace( $this->page, '', $link ); } return $link; } // If the .php filename is present in the link if ( false !== strpos( $link, $this->page ) ) { return str_replace( $this-> page, $this->page . '/' . $code, $link ); } return str_replace( $server, $server . $code . '/', $link ); } } I'm calling it this way: // code for header module: // Returns a button on a <div> $data = new FWR_language_selection( $navigation, $language, ( isset( $lng ) && ( $lng instanceof language ) ) ? $lng : false, $session_started , 'hreflink'); [...] // code for header_tags module: // Returns a <meta> $data = new FWR_language_selection( $navigation, $language, ( isset( $lng ) && ( $lng instanceof language ) ) ? $lng : false, $session_started , 'button'); The second time I use it will throw the error. May it be a problem related to instancing the same class twice? It's beyond my knowledge. Any help?
  4. @@clustersolutions I've finally found what was causing the Unable to determine the page link. I was using the code for language selection from here http://www.oscommerce.com/forums/topic/336702-ultimate-seo-urls-5-by-fwr-media/?p=1573463, slightly modified to show a language icon on header and a hreflang meta tag in the code. I made two modules one for each task (one for header and the other for header tags) and I've found If you call FWR_Language_Selection class twice in the same page it will throw the error and second call will fail. I'll try to isolate the problem so both modules can work together. I tried to destroy the class instance after using it on the first module but it makes no difference. I think $page will not be passed second time but I'm not sure. If someone has a clue on why it will fail please tell me :)
  5. Love random errors... didn't work for days and today it's working, not a comma changed. @@clustersolutions I'll PM the link. Still didn't install any HT module, I meant Ultimate SEO. Please let me know if you see the error now :)
  6. @@clustersolutions I've double checked configure.php and it's correct. It fails with HT seo enabled or disabled, with or without cache and with or without SSL. Checked the addon install and it seems It's well done... I don't have a clue on wwhat's happening. I will start again so it might be a silly semi-colon somewhere! Other strange thing is, after a few clicks on other links and then clicking home the page displays well (w00t) it's driving me mad... I'll post what happens if I ever get it working fine :wacko:
  7. @@clustersolutions I had, if I remember well, some problems with file cache repeating title for a product on every others, but it was years ago and I can't remember exactly what it was. I changed to MySQLite cache and the problem dissapeared. Yes I installed under bootstrap.domain.com and also on localhost/bootstrap; both methods went wrong. Do you have a test site setup? If yes do you have SSL enabled or disabled? I fear that can be the problem. I should need to put my production site under maintenance and swap the files and I can't do it until this weekend. About MySQLite, I've read problems but I'm not sure if it is a problem with new php versions or with newest oscommerce. It seems to work ok on my production server at first (php 5.3) but I didn't try it in depth.
  8. I'm using latest oscommerce bootstrap 2334 from github, on a new blank install (test site). I use file cache as I found sqlite was not working. On the production site (oscommerce 2.2) it has been working for years (mysql and file system created problems back then so I've been using sqlite on this one). For now it's running on a subdomain and SSL isn't enabled, so maybe the problem resides there but it should work without SSL I think. The error shows only in the root of the site (with or without /index.php). I've tried it on a local windows server and it happens there, too... It's strange nobody else has mentioned it yet.
  9. @@clustersolutions I've just installed this contrib with help from your github. Now I'm facing the problem of getting an Unable to determine the page link warning on index page. Have you experienced this?
  10. Oh I understand - I use several shipping modules instead one.
  11. @@Mort-lemur I'm curious; I've seen the aadon you have posted and I don't see the diference with the standard osc behavior. Can you explain what it does different?
  12. I'm sorry @@chipshi11, I don't know well how UK is divided for postal service and if it will work well as for Spain. I've tested something similar and the drop down menu is not visible at first when you choose a country, but if the zone selected does not match the zones on the database oscommerce will throw an error and show the drop down. I must have added the option to show the dropdown as the country is selected as an addon, and will probably need some javascript. If you still consider it useful I'll tale a look and try to find if it is an addon or it was a hack I made. What version of oscommerce are you using?
  13. Once you set up all the zones your new customers will have to choose one from the list of zones you have set up instead of typing one. You may have to change existing customer's addresses with phpmyadmin to reflect the zones in the zones table. Then you add two geo zones, one local and the other for the rest of the UK. And then two shipping modules (both fixed rate) and point each of them to a geo zone. I think this should work without addons... It works for Spain, Germany, US and other countries already added to the osc database. I'm not sure if the UK zones are not in the database because they are not officialy defined or because nobody coded them into oscommerce. But that's a function that already works on oscommerce from the begining.
  14. You may define two zones for UK in location/taxes -> zones. There are already zones (regions, states...) defined for some countries but not for the UK.
  15. Hola @@raiwa, I couldn't find in the instructions how to change product_info.php. Changed both references you mentioned on previous posts, but now colorbox is not working and I have just one image. Don't know why, but I found this adddon doesn't use the new table for product images and uses a neww field on products table instead; so oscommerce finds only one image. I have to dig on it and see why. Also there are no explicit instructions on how to use it on other pages; I figure how it works from inspecting the code but it's not straight.
  16. @@raiwa, You mention it was tested on 2.3.4 BS but I couln't find instructions for it. Did I miss something? Thanks!
  17. I'll try your first solution, it sounds good. Will try mysqldumper too, it will be useful for sure, but I want to make an one-click tool because I think it's good for people who doesn't know how to use other tools. I think something similar into installation is a must for people upgrading their shops to newer versions.
  18. Thanks, I'll do it and compare response times. Anyway I think I'll need something else; it takes minutes to load. I think I've seen some tricks before on another util for importing data, but I can't remember where or how it did it. Maybe javascript?
  19. Whoops! I'm sorry found I posted in the wrong forum. i think it will fit better in the add-ons forum. Please any moderator feel free to move the topic.
  20. I'm lazy to create custom fields and move all the data from my 2.2 live shop each time I test a new version of oscommerce in my local server. Doing it by phpadmin is boring so I finally made a tool to extract the data from the live shop and place it on the test shop tables. I plan to upload the tool to the addons section but I have a problem. The php script I wrote has a function that reads data from old tables and inserts the results on the test server corresponding table. But now I'm facing the problem that the script takes too long to process bigger tables and I end up with a Maximum execution time error at the middle of the process. In my case I may have a few thousand rows in the bigger table, but I' m sure other shops will have even bigger databases. Do you know any solution (apart of increasing max_execution_time) to avoid the problem? Here's the function in case you want to take a look: function translada ($tabla, $campos) { $sql_insert = "INSERT INTO " . $tabla; $sql_insert .= " (".implode(", ", $campos).") "; // Abre dos conexiones a las bases de datos de origen y destino $conn = new mysqli(DESTINATION_SERVER, DESTINATION_USER, DESTINATION_PASS, DESTINATION_DB); // destino $conn2 = new mysqli(SOURCE_SERVER, SOURCE_USER, SOURCE_PASS, SOURCE_DB); // origen $customers_query = "SELECT * from " . $tabla; $origen = $conn2->query($customers_query); $contador =0; if ($origen->num_rows > 0) { while($row = $origen->fetch_assoc()) { $sql=""; $sql_values =""; $sql_values .= " VALUES ("; foreach ($campos as $valor) { $sql_values .= "'" . addslashes ($row[strval($valor)]). "'," ; } $sql_values = rtrim($sql_values, ','); $sql_values .= ")"; $sql = $sql_insert . $sql_values; if ($conn->query($sql) === TRUE) { $contador++; } else { echo "Error: " . $conn->error . "<br>"; } } echo $contador . " registros procesados en la tabla " . $tabla . ".<br>"; } $conn->close(); $conn2->close(); }
  21. Found this contrib and it's juust what I've been looking for Can't wait to see the fully functional version :)
  22. Hello Jack, I've updated this contrib and everything works fine except the Header Tags SEO Keywords section. When I click on the "get position" button of any keyword I always get a "0 / Not Found" message, even if I can manually find the results on the first few pages of Google Search. I've tried to increase the "pages" number and added the web address with and without the"www" with no luck. Any clue on what can I do to test what's wrong?
  23. Hello, For those with multilingual shops and google sitemap installed, you'll have duplicate products on sitemapProducts.xml: In usu5_sitemaps/index.php: Change (line 206) usu5_create_sitemap_set( $languages['directory'], $languages['code'] ); to: usu5_create_sitemap_set( $languages['directory'], $languages['code'], $languages['languages_id'] ); Also in line 165 change: $query = "SELECT p.products_id, p.products_date_added, p.products_last_modified FROM " . TABLE_PRODUCTS_DESCRIPTION . " pd INNER JOIN " . TABLE_PRODUCTS . " p ON p.products_id = pd.products_id WHERE p.products_status = '1' ORDER BY p.products_last_modified DESC, p.products_date_added DESC"; to: $query = "SELECT p.products_id, p.products_date_added, p.products_last_modified FROM " . TABLE_PRODUCTS_DESCRIPTION . " pd INNER JOIN " . TABLE_PRODUCTS . " p ON p.products_id = pd.products_id WHERE p.products_status = '1' AND pd.language_id = " . $languages_id . " ORDER BY p.products_last_modified DESC, p.products_date_added DESC"; This way the product page will not be added for each language installed. Hope it's useful for you.
×
×
  • Create New...