Home Add price beside Woocommerce Force Sells
Reply: 0

Add price beside Woocommerce Force Sells

user1994
1#
user1994 Published in April 21, 2018, 3:08 pm

Woocommerce Force Sells by default only lists the product titles. I need them to also show the product price in brackets beside each title. You can see it here like in this screenshot:

But it should be:

  • Birth Pool Hire Bond ($50.00)
  • Birth Pool Liner ($33.00)

Is there a filter I can use so that Force Sells puts the prices beside items? Barring that, how can I alter the Force Sells code so that it also outputs price as well?

This is the part of the Force Sells code that outputs the items under the add to cart box on single product pages:

    /**
     * Displays information of what linked products that will get added when current
     * product is added to cart.
     */
    public function show_force_sell_products() {
        global $post;

        $product_ids = $this->get_force_sell_ids( $post->ID, array( 'normal', 'synced' ) );
        $titles      = array();

        // Make sure the products still exist and don't display duplicates.
        foreach( array_values( array_unique( $product_ids ) ) as $key => $product_id ) {
            $product = wc_get_product( $product_id );

            if ( $product && $product->exists() && 'trash' !== $product->get_status() ) {
                $titles[] = version_compare( WC_VERSION, '3.0', '>=' ) ? $product->get_title() : get_the_title( $product_id );
            }
        }

        if ( ! empty( $titles ) ) {
            echo '<div class="clear"></div>';
            echo '<div class="wc-force-sells">';
            echo '<p>' . __( 'This will also add the following products to your cart:', 'woocommerce-force-sells' ) . '</p>';
            echo '<ul>';

            foreach ( $titles as $title ) {
                echo '<li>' . $title . '</li>';
            }

            echo '</ul></div>';
        }
    }
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308144 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO