Support » Plugin: TablePress » woocommerce shortcodes in table entries

  • Resolved bengii


    Hi Tobias – love the tables!

    I am using the woocommerce plugin and I wish for users to be able to click on first column table entry and just add it directly to the cart. Normally I put the [add_to_cart sku=’XXXXXX’] shortcode on a page. This allows users to click the name and the product is automatically added to the cart. Is it possible to somehow mimic this in a cell? ie can I somehow add a link to each column-1 table entry (and I have c. 50 rows).

    At the moment I have to manually check the [add_to_cart_url] on a page for each product, then read the resulting url, then add that to the href statement in the cell.

    This is error prone and is also likely to result in broken links if/when there are product changes or upgrades.


    thanks in advance


Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg


    Hi Ben,

    thanks for your question.

    I’m not sure if I understand completely.
    So, you are pasting [add_to_cart sku='XXXXXX'] into a page to get something like an “Add to Cart” button?
    And you want such a button in table as well? Why don’t you just use that Shortcode in the table cells?

    From what I understand, you are currently creating the links for the “Add to Cart” function manually from the result of that Shortcode and then create a manual link in the table, and that’s what you want more automated?


    Hi Tobias,
    I am moving from a page format to a table format so you are correct, I wish to add it to a cell – either when I click on an ‘add to cart’ icon or click on the name itself.

    Second part of your comment: Correct.
    1. There is a shortcode I can add which is as follows: [add_to_cart sku="XXXX"] This returns the price for the product plus an ‘add to cart’ button, but this is large and cumbersome for the cell. I guess doing some CSS would help me format that.

    2. There is a shortcode which I can add as follows: [add_to_cart-url sku="XXXX"] which returns a relative URL from the current page. Clicking this URL then performs the function of adding that product to the cart. By creating a full URL and linking this to product name I can get where I need to be, but is manual an prone to error / broken links when I add or change a product

    Any pointers welcome

    Plugin Author TobiasBg



    ok, thanks for the explanation.

    Unfortunately, I don’t really see ways for making this simpler in TablePress 🙁 If those are the only ways to retrieve the necessary URLs/data from the eCommerce plugin, you’ll have to go with that…

    Now, if you already have that Shortcode for the URL, why don’t you use HTML like

    <a href="[add_to_cart-url sku="XXXX"]">Product name for XXXX</a>

    That would save you from having to deal with URLs directly.


    Thanks Tobias,
    It is really close, I am getting some strange behaviour in the sense that I am changing the product correctly for each cell but when I hit the button sometimes it simply increments the count on the last selected product, plus when I refresh the page that increments the previously clicked product choice also.

    What I shall do is strip it back to basics, flush all caches, ensure that I get the basic code as you suggested working on a simple page, then when that it OK I add it back into table format.

    Thanks for the responsiveness and the suggestions – I shall report back tomorrow (client meetings in the morning).

    I shall hit the donate button on my way. Thanks!

    Plugin Author TobiasBg



    a first step to further investigate this could be to investigate the HTML code of the page, to see if the link HTML code there is correct (i.e. matches the HTML that the other Shortcode generates).

    And thanks for wanting to donate, I really appreciate it!


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘woocommerce shortcodes in table entries’ is closed to new replies.