• Resolved scottl31

    (@scottl31)


    Hi,

    Instead of Woocommerce products, we use custom posts in which we put the “add to cart” button by placing this code:

    [add_to_cart sku=”book356″ style=”border:0px; padding:0px;” show_price=”false”]

    This works great, and after clicking, a check mark and a “View cart” link appears next to it.

    We sell books, and all have 1, 2 or 3 editions, (hard, soft, ebook). And at the moment, we want to change the page and make the button, price, and edition take up less space.

    Do you know if there’s a way to change the button text for each edition to read Hard cover, Soft cover, or eBook based on the way we are doing it above? Possibly even by adding something in the button code itself?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 8 replies - 16 through 23 (of 23 total)
  • Thread Starter scottl31

    (@scottl31)

    I don’t see how the exporting would work. Each ID has to be associated with a product, so how would I associate the exported IDs with the proper products? I mean, there would need to be a field for them to go in my import database.

    Is there a field in WC or a plugin that would allow defining the ID in advance? Funny, when I set up this database, I built in a product ID field and have been keeping it filled all along. But I have never found a place in WC to use it.

    Hi @scottl31,

    Here’s how I thought it would work:
    1. You do a mass import of everything, no IDs are set, right?
    2. When they get imported, everything is automatically assigned an ID
    3. Doing an export will now give you all that same data you had previously, but now WITH the IDs that the products have
    4. You can now use those IDs to re-import/merge and you can use those IDs for your buttons.

    Does that make sense?

    You COULD set IDs in an import ahead of time, but the problem is that IDs are created in order, so it’s possible one of the IDs you are setting already exists so the import would fail.

    Thread Starter scottl31

    (@scottl31)

    It sort of makes sense. A lot of extra work.

    But I’m not clear how to do the export you mention. And what would I end up with? What I’d need is a column of IDs I could copy/add to my database.

    Can you tell me how I could define the IDs in advance? There would be no danger of an ID already existing because every book would of course have a unique ID, as defined in the import database. Also, even when we add only one book to the site, all books are imported again anyway, of course along with their unique IDs.

    Thanks!

    Thread Starter scottl31

    (@scottl31)

    Hi Mikey,

    Do you have a response to my last question?

    thanks,
    Scott

    Hi @scottl31,

    But I’m not clear how to do the export you mention. And what would I end up with? What I’d need is a column of IDs I could copy/add to my database.

    My idea is to just do a product CSV Export – this will include IDs listed in a column. You can do the export from the main Products page.

    Can you tell me how I could define the IDs in advance?
    There would be no danger of an ID already existing because every book would of course have a unique ID, as defined in the import database. Also, even when we add only one book to the site, all books are imported again anyway, of course along with their unique IDs.

    I still would not recommend this, because everything in WordPress has an ID – not just products. Pages, Posts, products, custom post types, you name it. You would have no idea if an ID already exists without looking through every one. If you wanted to give them IDs in advance, you would just set them in the CSV column when you are doing the import. If an ID already exists, it would just not import that item and it would have an error.

    Thread Starter scottl31

    (@scottl31)

    Are you saying that IDs are site/system wide thing which all the numbers are random and not sort of confined to specific ranges depending on if it’s a product or a post or whatever?

    Ok, but if the IDs are already set for every book and I am exporting them to get that ID. When importing, I’d actually be reapplying them to the books they already belong to. That is except if I have a new book. So I would like to try defining in advance in this way.

    My only problem is I don’t know where the field is in the Woocommerce product options set up so I can place my import token there. Again, I am using WP All Import with the WooCommerce Add-On Pro

    Hi @scottl31,

    Are you saying that IDs are site/system wide thing which all the numbers are random and not sort of confined to specific ranges depending on if it’s a product or a post or whatever?

    The numbers aren’t really random, they get assigned in order (1, 2, 3, etc) but they get assigned to everything. Not just Products. Images, Pages, Posts, Products, etc.

    One problem that can happen is say you want to add 2 products, and you give one the ID of 40, and the next one the ID of 41. Product 40 might have an image with it, and when it uploads that, it might get the ID of 41- and then the next product will fail because 41 already exists.

    That is except if I have a new book. So I would like to try defining in advance in this way.

    You can definitely try, beware of when it will fail like the example above. What you can do is import a new book without an ID – export it and it will be assigned a new ID automatically, then import it again with it’s new ID and the info you need. It’s almost like you’re making a “placeholder” on the first import.

    I haven’t used WP ALL Import much or Add-On Pro – so I would suggest asking them for help on that last quesiton.

    Thread Starter scottl31

    (@scottl31)

    Hi Mikey,

    Had to get on to something else for a bit, but now I’m back to this.

    So in starting to get this going, I tried just making a link like:

    https://yourgroovydomain.com/?add-to-cart=123

    And it of course loads the item in the cart. But the problem is that the site thinks that “?add-to-cart=123” is a page and tries to go there, and since there is no such page, it just goes to the home page. I was using a 404 to homepage plugin so I disabled it, but it still just goes to the home page.

    Is there a way to click this link and keep the user on the page that it was clicked on?

    Thanks!

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Custom Post “Add to cart” Buttons editing’ is closed to new replies.