You are here:  » Products from Merchant

Active Forum Topics


Products from Merchant

Submitted by babyuniverse on Sun, 2018-12-30 04:16 in

Hi,

I am sure I have done this before but cannot find it in the forums.

I have a wordpress site that has multiple posts, each posts is a merchant for example

Post 1 (ASOS)
Post 2 (Marks and Spencer)
etc

I also have PT installed which has the same merchants. I would like show xx number of random products for that merchant on the merchant posts.

Shortcode would be [pto merchant="ASOS" results="20" sort="random"] or similar?

Is this possible?
Thanks
richard

Submitted by support on Mon, 2018-12-31 10:25

Hi Richard,

Sure that can be achieved; firstly to add support for the new attributes results and sort, edit pto.php and look for the following code at line 770:

    if (isset($atts["maxprice"])) $pto_maxPrice = $atts["maxprice"];

...and REPLACE with:

    if (isset($atts["maxprice"])) $pto_maxPrice = $atts["maxprice"];
    global $pto_config_resultsPerPage;
    global $pto_sort;
    if (isset($atts["results"])) $pto_config_resultsPerPage = $atts["results"];
    if (isset($atts["sort"])) $pto_sort = $atts["sort"];

And to add rand as a sort option, edit pto_search.php and look for the following code at line 339:

  $orderBy["priceDesc"] = "minPrice DESC";

...and REPLACE with:

  $orderBy["priceDesc"] = "minPrice DESC";
  $orderBy["rand"] = "RAND()";

And then use in your posts, for example:

[pto search="merchant:ASOS" results="20" sort="random"]

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by babyuniverse on Tue, 2019-01-01 07:47

I ended up using [pto featured="merchant:Shaver Shop:10"] based on the other post.

Submitted by firstbye on Wed, 2019-09-11 04:54

Hi David,
Great mod... Is it possible to modify the above so that I can get rid of the "Search Results/Banner" and "Search Results/Navigation" and just have the grid?

Cheers
Fb

Submitted by support on Wed, 2019-09-11 08:50

Hi Fb,

Just to confirm, as the banner / navigation are appearing that would indicate that you are using the shortcode on the /shopping page (or whatever you are using as the container permalink - the page with the [pto] shortcode...) - is that the case?

The reason I ask is that the code in pto_search.php is set-up to only show the banner / navigation on that page; if the [pto search="keywords"] shortcode is used anywhere else on the site only the results should be displayed...

Cheers,
David.
--
PriceTapestry.com

Submitted by firstbye on Fri, 2019-09-13 16:49

Hi David,

Ok.. I understand.
I've edited the WP template footer and I had added the above shortcode appear in the product page.

Which [PTO] shortcode should I be using? or can i use modified version of the "related" product table? basically I'd to be able to display a random selection of products from the same merchant.

cheers
Fb

Submitted by support on Mon, 2019-09-16 09:43

Hi,

You could modify the Featured Products shortcode handler to support special section names e.g. merchant:Merchant Name:3 for 3 random products from "Merchant Name".

To do this, Edit pto_featured.php and look for the following code beginning at line 37:

  if ($section)
  {
    $sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."featured` WHERE name LIKE '".esc_sql($section)."/%' ORDER BY sequence";
  }

...and REPLACE with:

  if ($section)
  {
    $parts = explode(":",$section);
    switch($parts[0])
    {
      case "merchant":
        $sql = "SELECT name,1 AS sequence FROM `".$pto_config_databaseTablePrefix."products` WHERE merchant = '".esc_sql($parts[1])."' ORDER BY RAND() LIMIT ".$parts[2];
        break;
      default:
        $sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."featured` WHERE name LIKE '".esc_sql($section)."/%' ORDER BY sequence";
        break;
    }
  }

And then use the shorcode:

[pto featured="merchant:Merchant Name:3"]

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by firstbye on Thu, 2019-09-19 09:29

Hi David,
Thanks for that. I've made the changes and added the shortcode to a page but it only displays the shortcode.

I check to see if [pto featured="section"] works and thats fine.

Not sure what I've missed.

Cheers
Fb

Submitted by support on Thu, 2019-09-19 10:28

Hi,

Sorry about that - i'd left a part of the standard section SQL in to the merchant version so nothing would have been returned - corrected above...

Cheers,
David.
--
PriceTapestry.com

Submitted by firstbye on Wed, 2019-10-02 11:40

Thanks David.
That worked.

Cheers FB