Support » Plugins and Hacks » eshop plugin – How to create a custon add to cart button?

  • I have a custom template for selling books.
    I add this code in my index.php for each post to add custom “add to cart button”:

    <?php $eshop_product=get_post_meta( $post->ID, '_eshop_product',true ); ?>
    
    			<input type="hidden" name="option" value="Option 1" />
    			<input type="hidden" name="qty" value="1" />
    			<input type="hidden" name="pclas" value="<?php echo $eshop_product['shiprate'] ?>" />
    			<input type="hidden" name="pname" value="<?php echo stripslashes(esc_attr($eshop_product['description'])) ?>" />
    			<input type="hidden" name="pid" value="<?php echo $eshop_product['sku'] ?>" />
    			<input type="hidden" name="purl" value="<?php echo get_permalink($post->ID) ?>" />
    			<input type="hidden" name="postid" value="<?php echo $post->ID ?>" />';
    			<input class="Boton_Comprar" value="Comprar" title="Agregar el producto seleccionado a la orden de compra" type="submit" />

    But this code not work, because the $eshop_product variable is empty, then the cart not show anything.
    I think i need aditional lines to fix it.
    Someboy can help?
    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Why are you doing it like that?
    what is that extra field for?
    What exactly are you trying to achieve?

    my site is mundoaeronaval.com
    I show a lot of post per page, and each post have a “add to cart button”, named “comprar” in spanish.
    When the visitor click in one button, the post/article is added to the cart, but the buttons not working.
    I use each button in a <form>.

    so you just want to show an image as opposed to the standard submit button?
    is that correct?

    I want to fix the code that I put in the first post of this thread because I couldn´t add anything in the shopping cart.
    The buttons in the index.php of the site do not work, so the visitors can´t add anything at the cart.
    Wich is the correct code to add a button to “add to cart” ?

    Sorry, english is my second language.

    Best regards.

    The plugin does add it automatically, or you can use the shortcode [eshop_addtocart].

    to change the button to an image, you just change the setting on the Settings > eShop page.

    I must do the modifications inside the index.php of my custom theme, so if I understand y must replace the code with this:

    <?php [eshop_addtocart class="custombutton"] ?>

    Where I put the name of the custombutton.jpg in the eshop plugin, inside the css?

    “to change the button to an image, you just change the setting on the Settings > eShop page.” ok, I did it.
    Inside de posts of my site, now appear a image replacing the button “add to cart”. Where can I change the image showed in the post?

    Best regards.

    in the wp-content/uploads/eshop_files directory.

    I must do the modifications inside the index.php of my custom theme, so if I understand y must replace the code with [eshop_addtocart], but not work. I try this:

    <?php [eshop_addtocart class="custombutton"] ?>

    and this:

    <?php echo do_shortcode('[eshop_addtocart class="Boton_Comprar"]'); ?>

    But this two codes not generate any php code.

    Which is the correct php code to put inside the index.php?

    Sorry just realised you are trying to use that shortcode outside of a post/page content – it isn’t set up to handle that.

    Look at using the eshop_show_product shortcode instead. check this page for what attributes you can use: http://quirm.net/wiki/eshop/shortcodes/

    especially the form.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘eshop plugin – How to create a custon add to cart button?’ is closed to new replies.