• Resolved Jay

    (@aaronholt)


    Hi,

    I’m currently working on a website for a client, and their product catalogue is supplied by a third party website, via an iframe. I’m well aware of the downsides of doing things this way, however with a constantly changing catalogue of over 22000 products, maintaining the catalogue themselves would be impossible as a small business.

    It’s all working fine, having added the products to the WooCommerce database, however I’m at a loss as to how I can reference products via the add-to-cart url. Each of the products has a unique SKU, which is the database field I’d like to add to the cart with, however WooCommerce seems to be enforcing that I can only add products to the cart using the id, which the third party catalogue obviously can’t provide.

    Is there a way around this?

    Kind regards,
    Aaron

    https://www.ads-software.com/plugins/woocommerce/

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    Do you even need cart functionality? Would it make more sense to link to the external add to cart url?

    Thread Starter Jay

    (@aaronholt)

    It would be ideal if I didn’t have to import the entire catalogue and periodically update it, but how would WooCommerce work without it? Clearly you’re more in the know than me, so I’d love to find out how ??

    In reality, the majority of customers are probably only occasionally going to be purchasing more than one product, but there is still the potential that they would do so.

    I’ve imported the catalogue, and it all works fine while utilising WooCommerce’s imported catalogue. My issue is how I’m going to get around WooCommerce insisting on add-to-cart via id rather than being able to use the SKU code. The ID is obviously only relevant within the WordPress database, so the external third party iframe catalogue has no way of knowing that ID.

    Many thanks for your reply by the way, very interested to find out what alternative solutions you can suggest

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Are the customers going to be using WooCommerce checkout and cart or sent offsite?

    Thread Starter Jay

    (@aaronholt)

    Customers will be using WooCommerce Cart and Checkout, with a payment gateway already in place

    Thread Starter Jay

    (@aaronholt)

    The iframe is only to provide the catalogue. The iframe is from a supplier of my customer, so the customer is completing the transaction on the site.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Ok, so I see 2 possible ways of doing this.

    1. You do imports. You don’t need to add to cart by SKU, just use whatever ID is given. SKU is stored within each product.

    2. You create a bridge plugin and 1 product which captures SKU via some custom field and sets price dynamically. User purchases that 1 product, with different SKU, each time.

    Thread Starter Jay

    (@aaronholt)

    The first option would be preferable, however the catalogue is hosted by the third party and it’s not possible to amend the catalogue from their end in any way. The second option does seem like it’s going to be the route I’m going to have to go down, but it seems a lot of work when all I really want to do is get the add-to-cart function to add products to the cart via the SKU stored in the database, as opposed to the ID?

    Thread Starter Jay

    (@aaronholt)

    I know it seems like I’m being awkward, but the third party catalogue can be configured so much as the add-to-cart url which is present from their catalogue, but the unique identifier it passes is the SKU / product code for their products. All those SKU’s are already stored in the WooCommerce imported catalogue, it’s just this manipulation of the add-to-cart functionality, and allowing that url to respond to SKU instead of ID

    Plugin Contributor Mike Jolley

    (@mikejolley)

    It’s not just that because you need something on your store to purchase. So it’s either an imported item, or a dynamic item (suggestion #2).

    Yes there is some code involved for #2 but it doesn’t sound overly difficult for a dev to implement.

    Thread Starter Jay

    (@aaronholt)

    I’ve imported the 20,000+ products, so the catalogue has been replicated (a lengthy CSV import), it’s literally just the problem of not getting WooCommerce to add-to-cart via SKU.

    Each and every product has a unique SKU, which is common between the WooCommerce catalogue of products, and that of the supplier within the iframe. The ID is independent to WooCommerce, so isn’t of any use when trying to add to cart via url.

    Option 2 would be fine in principal, so much as creating a reference table which would match up ID’s and SKU’s, but with that many products and a monthly update on the catalogue itself, it sounds like it could end up becoming very tedious.

    I know I keep harping on, but there must be a way I can manipulate the WooCommerce add-to-cart url shortcode to catch the SKU rather than the WordPress ID?

    Plugin Contributor Mike Jolley

    (@mikejolley)

    I don’t understand why you need to. Where are you passing these cart URLs? Why are they not just powered by WooCommmerce and it’s own IDs?

    Thread Starter Jay

    (@aaronholt)

    All the products are imported from a third party suppliers catalogue. Their online catalogue iframe is well organised and with imagery etc. Only reason for importing the catalogue is so WooCommerce can add the product to the cart, with its weight, to calculate shipping etc. WooCommerce is solely functioning as the cart / checkout, and not the catalogue itself. The website customers will be shopping within the iframe.

    The catalogue provided by the third party is within the iframe, and has ‘add to cart’ buttons on each product, which have the required add-to-cart url attached.

    If I had to fully import 22,000 products, including images, and update them on a monthly basis, I’d end up becoming a full time data entry clerk.

    Literally all I need to do is get WooCommerce to be able to add products using add-to-cart via SKU rather than by WooCommerce’s post-assigned ID.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Which brings us full circle.

    You need a bridge plugin. You can use a custom add to cart endpoint, capture SKU, lookup ID from SKU using PHP/MYSQL and add the product to the cart by ID.

    Thread Starter Jay

    (@aaronholt)

    OK great. I know it makes sense, was just hoping there was a simpler solution. Is there a tutorial or example of how this might be done?

    Thanks

    Plugin Contributor Mike Jolley

    (@mikejolley)

    I don’t think you’ll find one since this is a niche area. If you need dev help, try jobs.wordpress.net

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Add-to-cart by url – add product by SKU’ is closed to new replies.