Jump to content

Upgrade to CubeCart 6.1.0 With Custom Skin


Recommended Posts

Hi!

Looking at the new stuff in the update, it looks great!

I am about to upgrade from the most recent version 6.0.12 to 6.1.0

I have been using a slightly customized skin of the standard one, and want to know if I need to add the changes to the customized template I am currently using to the new upgrade.

The customizations are mostly some text, and some boxes, as well as a couple of links (like a link going to my WordPress page on the cart).

Thanks!

Link to comment
Share on other sites

Assuming your custom skin is based on CubeCart's Foundation skin, you can use Git to help you apply all of the changes between when you made the skin and now, even if you've never used Git before.

If you've got 15 minutes, you can try it yourself:

1. Install Git for your operating system: https://git-scm.com/downloads

   When installing it, keep in mind that you'll likely want to be able to open a Git shell from anywhere, so if you see an option like that during installation, make sure it's enabled!

2. Create a folder somewhere that will be convenient to work on your skin, e.g. c:/wamp/www/git/cubecart_skin

3. Open a Git shell ('Git Bash') in the folder you just created - in Windows, you should be able to do so by ctrl-right-clicking in file explorer and selecting it from the menu

4. In the shell that opens up, enter each command below that follows a '>' symbol:

    Do NOT forget the ending '.' - that tells it to clone in the current directory
    (assuming you opened the Git Bash from the directory you want, otherwise you
     should specify the directory e.g. c:/wamp/www/git/cubecart_skin)
    > git clone https://github.com/cubecart/v6 .

    Checkout whichever version tag your current skin is based off of, e.g. v6.0.12.
    Git will warn you that you are in 'detached HEAD' state - don't worry :)
    > git checkout v6.0.12

    Switch to your new branch! Yay!
    > git checkout -b custom_skin

   What that all does is set up a copy of CubeCart's code repository, reverts the code to whatever previous version you based your skin on, and then creates and moves to what is called a 'branch' - so long as you are on this branch, you can play with the code to your heart's content without fear of breaking anything.

5. Copy and paste your current skin into /skins/foundation, overwriting all existing files. Don't worry - you are still on your custom_skin branch so you won't be messing up CubeCart's code, but you can now see exactly what you changed!

If you want to see what you changed using the command line:

    Show all files you modified:
    > git status

    Show all changes you made - green for additions, red for deletions:
    > git diff master

    Show changes you made to a specific file:
    > git diff master <filename>
    e.g. > git diff master skins/foundation/templates/box.basket.php

6. Stage and commit (basically 'save') your custom skin changes so we can get the latest changes more easily:

    > git add --all

    > git commit -m "My custom skin based on the Foundation skin by CubeCart"

7. Now you're ready to apply whatever awesome updates have happened and apply them to your skin! The master branch should still have the latest code, so you can choose to merge all of the latest code OR you can choose to merge only up to the latest release:

    > git merge master

    OR

    > git merge v6.1.0

  If you only made a few changes (or if you are lucky), everything will go smoothly and your skin will be all up to date! If not, you'll see the following terrifying message: "Automatic merge failed; fix conflicts and then commit the result." This is likely going to take longer than 15 minutes now, but don't give up yet! See below for conflict resolution.

8. Now you just need to upload your newly updated skin to your site! Copy all the files in /skins/foundation to wherever your site is stored and all should be well.

KEEPING UP TO DATE
Keeping up to date is easy - simply open the Git Bash shell in the directory where you cloned the CubeCart repo and type the following commands:

    Make sure you are on the master branch
    > git checkout master

    Download all of the latest updates
    > git pull origin master

    Switch to your custom skin branch
    > git checkout custom_skin

    Merge the changes in!
    > git merge master (or whatever CubeCart version tag you wish)

CONFLICT RESOLUTION
Conflicts occur when both you and the CubeCart team have modified the same areas of the same files. Often you can resolve it simply by editing the file and removing whichever change you don't want, but sometimes you will need to combine the changes somehow.

When you open a conflicted file in your text editor, you will likely see "<<<<<< HEAD", "=========", and ">>>>>>> master" scattered throughout the file; all the code between "<<<<< HEAD" and "=========" is from the current branch, and the code between the "=========" and ">>>>>>> master" is from the branch you are merging changes from ('master', in this case).

As mentioned, you usually decide to keep one or the other, but you need to compare carefully as there could be important changes that were made. For a skin, it is often easier to keep the 'master' code and reapply whatever changes you had made manually on top of it.

Here is a brief workflow for resolving conflicts:

    To find which files require conflict resolution:
    > git status

    - Open each conflicting file in your favorite text editor and resolve the conflict.

    > git add --all

    > git commit

    - You'll likely see a bunch of colored text at this point - this is the VIM editor. To save and exit, type a colon ':' followed by the letter 'x'.

    - The merge may now continue, possibly resulting in further merge conflicts; follow the workflow again to resolve them and continue with the merge.

Conflict resolution can be scary, but there are lots of online resources discussing merge conflict resolution in Git as well as a fair number of tools - try a few out, take your time.

Most importantly, if (haha, when!) you ever completely screw up, DO NOT PANIC! It can be fixed so long as you don't panic and do something irreversible, and even then most things aren't really irreversible in Git especially if you DO NOT PANIC.

If you're not confident with Git, then stop what you are doing, keep the bash shell or whatever tool you were using open, and ask for help from a more knowledgeable friend, in an online forum, or on a site like StackOverflow.

CLOSING WORDS
Please do not let the section on conflict resolution scare you away - Git is an amazing tool. It does take time to learn, many commands are far from intuitive, and there will likely be days when you hate it, especially in the beginning. If you stick with it, however, Git can make your coding life so much easier.

There are also some very good graphical programs (such as Atlassian's SourceTree) that make using Git more intuitive for a lot of people - I recommend giving one or more a try.

Also, I am not affiliated with Git or any other website or product mentioned in this post, in case that matters to anyone.

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.

×
×
  • Create New...